Data Binding Wizard in Delphi XE - can It be configured to map to MSXML interfaces?

断了今生、忘了曾经 提交于 2019-12-23 15:02:13

问题


The Data Binding Wizard in Delphi XE generates classes and interfaces that inherit from Delphi's own implementation of the DOM (ADOM XML v4), which doesn't appear to support validation against schemas - the 'validate on parse' option only works with the MSXML vendor type - as can be seen from the VCL source code and also the behavior of XMLDocument component in the IDE. All validation support seems to be based on the MSXML implementation, which makes the wizard useless if you need schema validation. Am I missing something here?

Is there a way to configure the binding wizard (or some underlying utility) to generate classes and interfaces based on MSXML, which supports validation?

Or are there calls/interfaces that support schema validation using Delphi's implementation of ADOM XML that I haven't come across?

MNG


回答1:


The code generated by the XML Data Binding Wizard depends on the units XMLDoc and XMLIntf (the document references are TXMLDocument and IXMLDocument).

IXMLDocument is implemented by TXMLDocument, which is the generic wrapper around XML DOMs supported by Delphi. The DOM used by TXmlDocument depends on the value of the DOMVendor property.

If a DOMVendor is not specified when activating a TXMLDocument instance (it isn't as the XML Data Binding Wizard generates DOM neutral code), then the actual XML DOM used depends on these two members of the XMLDOM unit:

var
  DefaultDOMVendor: string;
  DOMVendors: TDOMVendorList;

In your case, it appears that the MSXML DOM is either the default XML DOM, or the only XML DOM available.

So you should check the values of DefaultDOMVendor and the DOMVendors list.

It would certainly help if you can edit your question with the values of the above, and a reproducible case that shows how you observed the MSXML DOM is being used.

Edit:

You can fore the run-time use of a specific XML DOM vendor right before you load your XML root node, or create a new XML root node like this:

DefaultDOMVendor = 'MSXML';


来源:https://stackoverflow.com/questions/5775102/data-binding-wizard-in-delphi-xe-can-it-be-configured-to-map-to-msxml-interfac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!