Jump to content

Working with Schema Indicators


essdog
 Share

Recommended Posts

Hi everyone, I am new to creating XML schemas and I ran into a problem doing so for an existing XML document. I have one element that (this doesn't compile) looks basically like this: <xs:complexType name="type0"> <xs:someIndicator> <xs:element name="elem0" type="xs:string" minOccurs="1" maxOccurs="1" /> <xs:element name="elem1" type="xs:string" minOccurs="1" maxOccurs="1" /> <xs:element name="elem2" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> </xs:someIndicator> </xs:complexType>As far as indicators go, I only have three options all, sequence and choice: * All will not work because my elem2 maxOccurs attribute is "unbounded". * Sequence won't work because sometimes elem1 precedes elem0. I would change this but the current document I'm working with is 4000 lines long and would take a long long time. * Choice won't work for me either because I need more than 1 element to show up. What I'm basically trying to do is find a way so that for one complexType, have 3 element types as children that can be in any order and one of them can appear an unlimited number of times. Can someone please help me out with this? I would greatly appreciate it. :)

Link to comment
Share on other sites

What about using sequence, and creating two different sequences, one when elem0 is before elem1, and another for the other case. Then put those two sequences in a choice, itself in a complexType ?Not clear ? I'll try with an example :

<xs:complexType name="type0">  <xs:choice>   <xs:sequence>    <xs:element name="elem0" type="xs:string" minOccurs="1" maxOccurs="1" />    <xs:element name="elem1" type="xs:string" minOccurs="1" maxOccurs="1" />    <xs:element name="elem2" type="xs:string" minOccurs="0" maxOccurs="unbounded" />   </xs:sequence>   <xs:sequence>    <xs:element name="elem1" type="xs:string" minOccurs="1" maxOccurs="1" />    <xs:element name="elem0" type="xs:string" minOccurs="1" maxOccurs="1" />    <xs:element name="elem2" type="xs:string" minOccurs="0" maxOccurs="unbounded" />   </xs:sequence>  </xs:choice></xs:complexType>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...