XML Schema sequenceElement
Complete XML Schema Reference Manual
Definition and Usage
The sequence element requires that the elements in the group appear in the specified order within the containing element. Each child element can occur from 0 to any number of times.
Element Information
- Parent element: group, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
Syntax
<sequence
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
(? declares that the element may appear zero or one time within the sequence element.)
| Attributes | Description |
|---|---|
| id | Optional. Specifies a unique ID for the element. |
| maxOccurs | Optional. Specifies the maximum number of times the any element may appear in the parent element. The value can be an integer greater than or equal to zero. To specify no maximum limit, use the string "unbounded". The default value is 1. |
| minOccurs | Optional. Specifies the minimum number of times the any element may appear in the parent element. The value can be an integer greater than or equal to zero. To specify that the any group is optional, set this attribute to zero. The default value is 1. |
| any attributes | Optional. Specifies any other attributes with non-schema namespaces. |
Example 1
This example is a declaration for the "personinfo" element, which must contain the following 5 elements in order: "firstname", "lastname", "address", "city", and "country".
<xs:element name="personinfo">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Example 2
This example is a declaration for the "pets" element, which can contain zero or more dog and cat elements:
<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>
<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>
Complete XML Schema Reference Manual Other Extensions