Elliott
Elliott

Reputation: 5609

The meaning of the sequence XSD tag

I'm unclear about how the definition of a sequence works.

On the ww3 school website, the following example is given:

<xs:element name="pets">
  <xs:complexType>
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="dog" type="xs:string"/>
      <xs:element name="cat" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

Of which is said

The Example shows a declaration for an element called "pets" that can have zero or more of the following elements, dog and cat, in the sequence element:

But what does this mean? Could there be 5 dog elements and no cat elements. Or 3 cat elements and no dog elements? Or do cat and dog elements always have to occur together and when they do, they can occur together between 0 and some undefined number of times.

Upvotes: 0

Views: 188

Answers (1)

Michael Kay
Michael Kay

Reputation: 163625

I find w3schools a useful resource for reminding yourself of syntax details you once knew, but it's not a good place to go if you're learning new concepts. Get yourself a good book on XML schema, for example those by Priscilla Walmsley or Eric van der Vlist - and read it.

The syntax you show is like (dog, cat)* in a regular expression: that is, any number of repetitions of the sequence (dog, cat).

Upvotes: 1

Related Questions