Esquema XML maxOccurs y xs: todos

I got the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="machine">
    <xs:complexType>
    <xs:sequence>
      <xs:element name="states" type="tokenList"/>
      <xs:element name="in_alphabet" type="tokenList"/>
      <xs:element name="blank" type="xs:string"/>
      <xs:element name="tape_alphabet" type="tokenList"/>
      <xs:element name="first_state" type="xs:string"/>
      <xs:element name="final_states" type="tokenList"/>

      <xs:element name="delta" type="delta_func" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name="tokenList">
    <xs:list itemType="xs:normalizedString"/>
  </xs:simpleType>

  <xs:complexType name="delta_func">
    <xs:sequence>
      <xs:element name="state" type="xs:string"/>
      <xs:element name="read" type="xs:string"/>
      <xs:element name="target_states" type="tokenList"/>
      <xs:element name="write" type="xs:string"/>
      <xs:element name="move">
        <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="R|L|r|l"/>
        </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

</xs:schema>

Which works, but I would like to not restrict the order of the elements. I tried xs:all but it doesn't allow maxOccurs=unbounded para delta, which is a must. All other elements occur only once, so xs:all wouldn't be problem here. Is there a way to define random order on the element while allowing an unlimited numbers of deltas?

preguntado el 01 de febrero de 12 a las 14:02

2 Respuestas

XSD 1.1 allows what you are looking for: xs:all with a maxOccurs on each element particle.

Respondido 01 Feb 12, 20:02

En lugar de <sequence>, podrías usar <choice maxOccurrs="unbounded">, but it would imply that all elements can occur more than once.

Respondido 01 Feb 12, 18:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.