Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSD and free order in sequence

Status
Not open for further replies.

castali

Programmer
Jan 26, 2004
24
DE
I have the following schema (xsd)

<xs:element name=&quot;subMenuBar&quot;>
<xs:complexType>
<xs:sequence>
<xs:element ref=&quot;item&quot; maxOccurs=&quot;unbounded&quot;/>
<xs:element ref=&quot;separator&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;unbounded&quot;/>
</xs:sequence>
</xs:complexType>
</xs:element>

but I want to be able to put in any order item or separator

item
separator
item
item


and with this schema

actually I can only put the separator after all items


what is the xsd syntax for it ?

thank you
 
Define a repeating element. Underneath that element define a choice that selects either your item or separator.
[tt]
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<xs:schema xmlns:xs=&quot; elementFormDefault=&quot;qualified&quot; attributeFormDefault=&quot;unqualified&quot;>
<xs:element name=&quot;Root&quot;>
<xs:complexType>
<xs:sequence>
<xs:element name=&quot;ItemOrSeparator&quot; maxOccurs=&quot;unbounded&quot;>
<xs:complexType>
<xs:choice>
<xs:element name=&quot;Item&quot;/>
<xs:element name=&quot;Separator&quot;/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
[/tt]
Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
ItemOrSeparator is not recognized , I get an error in the xml file

thank you for helping
 
Yes, well it's needed to get the behavior you want.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
I get it

<xs:element name=&quot;subMenuBar&quot;>
<xs:complexType>
<xs:choice maxOccurs=&quot;unbounded&quot;>
<xs:element ref=&quot;item&quot;/>
<xs:element ref=&quot;separator&quot;/>
</xs:choice>
<xs:attribute name=&quot;id&quot; use=&quot;required&quot; type=&quot;xs:string&quot;/>
</xs:complexType>
</xs:element>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top