[xsd-users] Extracting DOMDocument from anyType
Boris Kolpackov
boris at codesynthesis.com
Tue Jan 23 06:44:19 EST 2018
Iain Sharp <isharp at atis.org> writes:
> I now want to expand the parsing to extract an appropriate type instance for
> an anyType element which will contain one of the types already handled by
> the parser. To do this, the obvious thing is to get the DOMDocument for the
> anyType and pass this through steps 3 and 4 of the existing parsing process
> above. However, the dom_content_document() for the anyType element doesn't
> seem to be returning a populated document.
>
> I have processed the XSD using "-generate-any-type". If I call dom_content()
> on the anyType element then I see all the tags and values belonging to the
> contained type as I would expect. However, dom_content_document() doesn't
> seem to contain any data:
>
> xercesc::DOMDocument& dcd = anyTypeElement.dom_content_document();
> dcd.getNodeName() is "#document"
> dcd.hasChildNodes() is false
> dcd.getDocumentElement() is NULL
The DOMDocument returned by dom_content_document() is the "container"
document for wildcard content. If you have 10 elements of anyType in
your document, then they will all be "owner" by a single DOM document
(as opposed to 10 different documents).
To handle wildcard content you will need to directly call the parsing
constructors for the corresponding types instead of going through the
parsing functions (which are used for root elements only). See the
'cxx/tree/wildcard' example for details.
Boris
More information about the xsd-users
mailing list