tags:

views:

12

answers:

0

I want to create an XML schema that contains the following:

<xs:complexType name="Record">
        <!--required elements-->
        <xs:element name="RecordTag" type="xs:string" minOccurs="1" maxOccurs="1" />
        <xs:element name="RecordSize" type="xs:string" minOccurs="1" maxOccurs="1" />
        <xs:element name="RecordSection" type="xs:string" minOccurs="1" maxOccurs="1" />

        <!--optional elements-->
        <xs:element name="RecordName" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="RecordType" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="RecordValue" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="RecordDefault" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="RecordComment" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="RecordURL" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="Condition" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="Master" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="RecordCurrent" type="xs:string" minOccurs="0" maxOccurs="1" />
        <xs:element name="RecordId" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:complexType>

As you can tell by the comments, I want the top three elements to be required, and the rest are optional. The schema should allow for the elements to appear in any order.

Now, if I use the <xs:sequence> indicator, the order is enforced, which I don't want. If I use the <xs:all> indicator, then the schema requires all the elements to appear, even if the minOccurs value is set to 0.

Is there some other indicator that I can use to accomplish my task?

Thanks!