Question: My data structure looks like this

```
<datastructure>
  <field1>data</field1>
  <field2>data</field2>
  <field3>data</field3>
  <field4>data</field4>
  <field4>data</field4>
  <field4>data</field4>
  <field4>data</field4>
</datastructure>

```

All fields must appear exactly one time, except field4 which can appear [0, unbounded] times. Also there's no good reason to care about the order.

I could not come with a schema to validate this. Using sequence will work as:

```
<xs:element name="datastructure" type="datastructureType"/>
<xs:complexType name ="datastructureType">
  <xs:sequence>
    <xs:element name="field1"/>
    <xs:element name="field2" />
    <xs:element name="field3"/>
    <xs:element name="field4" minOccurs="0" maxOccurs="unbounded"/>
  </xs:sequence>
</xs:complexType>

```

But that imposes an order which I have no good reason for imposing. The alternative is using all, but that requires modifying the xml to:

```
<datastructure>
  <field1>data</field1>
  <field2>data</field2>
  <field3>data</field3>
  <field4List>
    <field4>data</field4>
    <field4>data</field4>
    <field4>data</field4>
    <field4>data</field4>
  </field4List>
</datastructure>

```

Because the children of all can only have maxOccurs up to one. This adds the burden of field4List, which seems to be useless in all practical regards. 

How can I write a schema that will validate my xml as does the sequence example, but that does not care for order? Or alternatively why such a schema would be a bad idea in the first place?

Answer: 
Please, check this out: [Middle way between XSD all and XSD sequence](https://stackoverflow.com/questions/839079/middle-way-between-xsd-all-and-xsd-sequence)
Cardinality restriction is a sever constraint for the use of xs:all in many real-world schemas. Relax NG is far more flexible from this point of view.

I should use the "field4List way"; it adds one additional element in your schema, but leave it unordered.