How to write in xsd a fixed sequence of choices



I need to produce an xml where a record is composed by different type of objects. But each record, in the same xml, has to have the same structure.



<xs:complexType name="record">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="type1" type="type1Type" />
<xs:element name="type2" type="type2Type" />
<xs:element name="type3" type="type3Type" />
<xs:element name="type4" type="type4Type" />
<xs:element name="type5" type="type5Type" />
</xs:choice>
</xs:sequence>
</xs:complexType>


Now I need to restrict each record to have the same sequence of choices without writing any combination of types.


Example: I should be able to write these records:



type1/type1/type3


type1/type1/type3


type1/type1/type3


type1/type1/type3



but I would like to write the limitation to write something like:



type1/type2/type3


type1/type1/type5


type3/type2/type5/type5


type1/type5



I don't know how to do and I looked everywhere to find a solution, Could be it not possible?


. Any record in the same xml has to be composed by the same objects!


No comments:

Post a Comment