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

Eric Broadbent eric.broadbent at csr.com
Mon Dec 12 14:19:03 EST 2011


Thanks Boris for your advice here, and sorry for the non-conforming post.
I will try content filtering as you suggest.  As it is I have no control over the schema so will have to deal with the rogue attributes.
Hopefully the subclass/override will end up being trivial, but if you or anyone else on the list knows of other examples of this kind of filtering, a link would certainly be helpful.
If I end up creating a successful filter I'd be happy to share how it was done.

-Eric

On Dec 12, 2011, at 9:37 AM, Boris Kolpackov wrote:

> 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
> 
> 
> To report this email as spam click https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg== .



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog



More information about the xsde-users mailing list