[xsd-users] Extracting DOMDocument from anyType

Iain Sharp isharp at atis.org
Tue Jan 23 08:02:41 EST 2018


Thanks - I guess that makes sense.

If I want to be consistent between how the root elements and the wildcard elements are created is there any reason not to use the constructors that take a DOMElement parameter in both cases?

Regards

Iain


-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: 23 January 2018 11:44
To: Iain Sharp <isharp at atis.org>
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Extracting DOMDocument from anyType

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