[xsde-users] Re: How to parse invalid XML when C++/Hybrid requires validation

Boris Kolpackov boris at codesynthesis.com
Mon Dec 12 09:37:11 EST 2011


Hi Eric,

In the future please use a new, descriptive subject for a new question,
instead of replying to an old thread. For more information, see Posting
Guidelines:

http://codesynthesis.com/support/posting-guidelines.xhtml

Eric Broadbent <eric.broadbent at csr.com> writes:

> However, I encountered this error when generating the code from the schema:
> 	"error: complex type 'CT_GForce' contains choice compositor"
> 	"error: parser validation is required to handle this construct"
> 
> Is there any way to deal with this?  The runtime error forced validation 
> off - whereas the code-generation wants validation on.

As the error suggests, C++/Hybrid needs validation if a schema contains
choice compositors. The reason for this is that in XML Schema to associate
content to choice arms one has to do full-blown validation. Because the
C++/Hybrid mapping needs this association, it requires validation if a
schema contains choice compositors.

IMO, the problem here is the invalid XML (per the schema) that you are 
trying to parse and the solution is to try and transform it to something
valid. I remembers you mentioned that the "extension" attributes/elements
can appear pretty much anywhere in the document. This means that what we
need is some kind of a global filtering mechanism. One way to do this
would be to intercept raw SAX callbacks (start element, end element,
characters) and filter the "extension" content at that level. You can
do this by inheriting from xml_schema::document_pimpl and providing
your own Expat callbacks after the call to parse_begin(). You will
also need to call the original callbacks if the content should be
parsed. See source code in libxsde/xsde/cxx/parser/expat/document.?xx
for details.

Boris



More information about the xsde-users mailing list