tags:

views:

70

answers:

2

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".

A: 

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:

marc_s
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".
Imageree
yes, that's a limitation of `<xs:all>` - maxOccurs can be only 0 or 1. You didn't mention anything else in your example, either.....
marc_s
+1  A: 

You want the All indicator (<xs:all>).

<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>

The XML Schema Tutorial on W3Schools is very helpful.

Jason
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".
Imageree