I hava a xml doc (and complex element) that is similar to this example:
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
But in my xml it shouldn't matter if I add firstname or lastname first. So I would like to remove the "xs:sequence" part but I am not sure what I should replace it with.
If it is not possible - then why is it not possible?
Update: If I change it with < cx:all> I get this error: "The {max occurs} of all the {parties} of an all group must be 0 or 1".
Use <xs:all>
instead of <xs:sequence>
:
<xs:element name="employee">
<xs:complexType>
<xs:all>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
See the W3Schools page on the schema indicators:
All Indicator
The
<all>
indicator specifies that the child elements can appear in any order, and that each child element must occur only once:
<xs:element name="employee">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="firstname" type="xs:string" />
<xs:element name="lastname" type="xs:string" />
</xs:choice>
</xs:complexType>
</xs:element>
This will allow you to have elements in any sequence and quantity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With