Jump to content
Sign in to follow this  
essdog

Working with Schema Indicators

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. :)

Share this post


Link to post
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>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...