[xsde-users] ignoring parts of the schema - and referenced schemas
Eric.Broadbent at csr.com
Tue Nov 29 00:29:17 EST 2011
Hi and many thanks for a very nice solution, I have found the generated code to be very efficient.
The schema that I need to work with contains elements which are defined in other schemas, so I have generated the various parser skeleton/implementation parsers individually and then linked them all together with the main schema driver (I'm testing the generated printf driver version).
The root element contains many elements, only two of which I'm really interested in parsing and building objects for, so I provided type-maps only for these two sub-elements. I've also followed the directions on page 20 of the "Embedded C++/Parser Mapping Getting Started Guide" to skip over elements that I don't care about:
"You might be wondering what happens if you do not provide a parser by not calling one of the *_parser() functions. In that case the corresponding XML content will be skipped, including validation. This is an efficient way to ignore parts of the document that you are not interested in.
An alternative, shorter, way to connect the parsers is by using the parsers() functions which connects all the parsers for a given type at once:"
First I tried this by passing NULL to the bundle-form of the _parsers() connection function, but I got compiler errors - so I had to use the one-by-one "*_parser()" functions, calling only the ones associated with the elements that I am interested in.
When I run the driver on sample XML docs, I get errors like this:
... test2.xml:2:381: unexpected attribute encountered
When I try to debug the code, I wasn't able to figure out where to break in an element handler to tell what element it's encountered, although I can find the element that is causing the problem via the error message "line:pos" notation.
The problem seems to be that I have not generated parsing code for all the possible schemas that can be referenced via attributes.
It seems that there can be "optional" elements, which essentially allow namespaces to be extended.
This looks something like this - appearing in any given element attribute list:
where "foobar" is an attribute in the schema XMLSchema-foo, and "bar" is yet another namespace represented by another schema.
The use of the "foobar" attribute to give meaning to the "bar" namespace is dependent on the ability to interpret the semantics of the "foo" schema.
As far as my application is concerned, I do not need to do anything with these attributes or namespaces, and I would like the parser to ignore them.
However, since this kind of namespace reference is dynamic, perhaps there is no opportunity to tell the parser to skip over these attributes - in the same way that we can tell it to skip over elements. Therefore I am not sure how to deal with this situation - except to have pre-processed any possible "optional" schema beforehand and built parsers for it.
My question is - is there any way to skip over unknown element attributes like this that are referring to other schemas that I have no handlers for (and no need for)?
Thanks again for the powerful software and the assistance using it.
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