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

Jonathan Haws Jonathan.Haws at sdl.usu.edu
Wed Dec 21 19:16:32 EST 2011


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!



More information about the xsde-users mailing list