Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XSD: Order irrelevant but choice required

From: Stephan Mann <groups@------------.-->
To: NULL
Date: 4/3/2009 5:32:00 PM
Hi,

I'm relatively new to XSD but I did not think that my requirement would 
prove to be such a problem. But after two hours of trying and searching 
I'm now thoroughly confused. Maybe someone could point me into the right 
direction.

Requirement: There are three elements. One is optional, while the other 
two are exclusively to each other. One of the latter might appear 
multiple times.

Therefore, I wrote the following XSD, which is working perfectly:

<xs:element name="Root">
   <xs:complexType>
     <xs:sequence>
       <xs:choice>
         <xs:element name="One" type="xs:string" maxOccurs="unbounded" />
         <xs:element name="Two" type="xs:string" />
       </xs:choice>
       <xs:element name="Description" type="xs:string" minOccurs="0" />
     </xs:sequence>
   </xs:complexType>
</xs:element>

It allows <One> multiple times OR <Two> once and <Description> is 
optional. The problem I can't get my head around is how to achieve that 
the order of the choice group and the description tag is irrelevant. 
<Description> should be allowed to occur first.

All my attempts to do that have failed. I'm not allowed to use <all> 
instead of <sequence>, because <all> is only allowed to contain 
elements. And if I replace the <sequence> with an

<xs:choice maxOccurs="unbounded">

the order is no longer relevant, but also an *empty* XML document is now 
valid (which had me surprised for a moment, but I think I understand it 
now).

I'm completely in the dark on how to achieve my additional requirement. 
Specifying all possible permutations in a choice of sequences is 
obviously no solution, since I need a lot more elements in the final 
XSD. It seems simple to me but I can't get it to work, so any help would 
be greatly appreciated.

tia, stephan




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent