XML Schema Data Type with Ordered and Unordered Elements

trinityinn

New Member
I am trying to create my own XML schema data type. Here's what I've done so far:\[code\]<xs:complexType name="MyType"> <xs:sequence> <xs:element name="Required1" minOccurs="1" maxOccurs="1"></xs:element> <xs:element name="Required2" minOccurs="1" maxOccurs="1"></xs:element> <xs:element name="Required3" minOccurs="1" maxOccurs="1"></xs:element> <xs:element name="Optional1" minOccurs="0" maxOccurs="1"></xs:element> <xs:element name="Optional2" minOccurs="0" maxOccurs="1"></xs:element> <xs:element name="Optional3" minOccurs="0" maxOccurs="1"></xs:element> </xs:sequence></xs:complexType>\[/code\]My requirements for this data type are as follows:[*]All of the "\[code\]RequiredX\[/code\]" elements are required (duh!) and must be in order.[*]All of the "\[code\]OptionalX\[/code\]" elements must appear after the "\[code\]RequiredX\[/code\]" elements.[*]No order should be imposed on the "\[code\]OptionalX\[/code\]" elements (e.g., "\[code\]Optional3\[/code\]" can come before "\[code\]Optional1\[/code\]").The last requirement is what is stumping me. I've tried using the \[code\]<xs:all>\[/code\] and \[code\]<xs:choice>\[/code\] elements in my schema data type defintion, but I haven't been successful. Can anyone help me?Edit: There is another requirement that (I hope) was implied (via the \[code\]maxOccurs="1"\[/code\] attributes) in my post...I will explicitly state it here for clarity: The "\[code\]OptionalN\[/code\]" elements should not repeat (i.e., I can have only one "\[code\]Optional1\[/code\]" element, only one "\[code\]Optional2\[/code\]" element and only one "\[code\]Optional13\[/code\]" element).
 
Back
Top