[xsde-users] xs:any and xs:anyAttribute

Eric Broadbent Eric.Broadbent at csr.com
Thu Dec 22 02:04:25 EST 2011


I am doing something like this, and have had several trial-and-error runs so far to get it to do what I want, but I'm almost there.  What I've done is to generate the code using separate invocations of XSD/e cxx-hybrid, with the first one working on all the sub-schemas - like this:

-> setenv XSDFLAGS "--generate-parser --generate-serializer  ... "
-> $XSDE cxx-hybrid  $XSDFLAGS \
sub-schema1.xsd  sub-schema2.xsd sub-schema3.xsd ... sub-schemaN.xsd

(Note I am setting other options in XSDFLAGS besides the ones above, but the critical ones are shown)
Then I change the flags to identify the root-element which I want XSD/e to generate an aggregate parser and serializer for, and I provide the main schema only in this invocation:

-> setenv XSDFLAGS "--generate-parser --generate-serializer  --generate-aggregate --root-element timing ... "
-> $XSDE cxx-hybrid  $XSDFLAGS \
main-schema.xsd

Then I compile all the code and link it - except the missing link is that I had to cobble together a "driver" by looking at the other example drivers, because the cxx-hybrid code-generator doesn't support the "--generate-test-driver" option.
It wasn't too hard to do, so if you get stuck with this let me know.

Eric B.
Zoran/CSR

On Dec 21, 2011, at 7:16 PM, Jonathan Haws wrote:

> I am getting started on a project where I have been provided with a few XML schemas in *.xsd files and am trying to figure out how I can get them all into a single parser.  These are CoT schemas, so I cannot change them.  I am also a noob when it comes to XML, but have a basic understanding of it.
> 
> Ideally what I would like to end up with is something similar to the Hello example where I parse whatever is coming in and serialize my data in the same way on the way out (I will only be supporting a single sub-schema during serialization).
> 
> Basically, this is what I have:
> 
> <event>
>  <point/>
>  <detail>
>    <!-- Varied schema(s) found in separate file is added here -->
>  </detail>
> </event>
> 
> Here is the schema for detail:
> 
> <xs:element name="detail">
>    <xs:annotation>
>        <xs:documentation>
>            format = XML schema defined outside of this document
>        </xs:documentation>
>    </xs:annotation>
>    <xs:complexType>
>        <xs:sequence>
>            <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
>        </xs:sequence>
>        <xs:anyAttribute processContents="skip"/>
>    </xs:complexType>
> </xs:element>
> 
> So, I could have something that looks like this in my XML input to the parser:
> 
> <event>
>  <point/>
>  <detail>
>    <shape/>
>    <color/>
>    <track/>
>    <link/>
>    <contact/>
>  </detail>
> </event>
> 
> Each separate element (shape, color, track, link, contact) each are defined in their own schema (separate XSD files).
> 
> Since I can have multiple elements from multiple schemas in the detail element, how can I generate the code for this?  I read the user guide on parser reuse, but did not see how it would do what I need it to do.  Also, the Wiki page on CoT refers to using XSD, but I am working in an embedded system, thus XSD/e is a better fit.
> 
> Anyway, is there an example that would show how this can be done?  Or can anyone answer my questions and/or guide me in the right direction?  It would be awesome to be able to support every single XSD file in parsing and serialization transparently.
> 
> Thanks!
> 
> Jonathan
> jhaws at sdl.usu.edu
> 
> PS - There is also a schema called Universal Core (or UCore) that I plan to use in the future as well.  It's schemas seem to be fashioned in the same manner as I am describing, so figuring this out now would be great!
> 
> Thanks!
> 
> 
> 
> 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