Purpose |
This element (the "sequence" particle) is used for expressing sequences in the content model of a complex type used for element definitions. This means that the child elements must appear in a given order. |
Parent element | xs:choice ,
xs:complexType ,
xs:extension ,
xs:group ,
xs:sequence |
Child elements | xs:any , xs:choice ,
xs:element ,
xs:group ,
xs:sequence
|
Attributes | minOccurs ,
maxOccurs |
Status | Optional. |
Name | Type | Description |
---|---|---|
minOccurs |
xs:nonNegativeInteger |
Together with the
maxOccurs attribute described below, this
attribute expresses multiplicity in TSD (and
XML
Schema) in sequence elements within a content model. The value of a
minOccurs attribute in an
xs:sequence declaration determines the minimum number of
occurrences of that sequence. The value of
minOccurs must be a non-negative integer. The
default value for minOccurs is 1.
|
maxOccurs |
xs:nonNegativeInteger or
"unbounded"
|
Together with the
minOccurs attribute described above, this
attribute expresses multiplicity in TSD (and
XML
Schema) in sequence elements within a content model. The value of a
maxOccurs attribute in an
xs:sequence declaration determines the maximum number of
occurrences of that sequence. The value of
maxOccurs must be a non-negative integer or the
value "unbounded". The default value for
maxOccurs is 1.
|
In the following example, within a p_record
element the five children from p_firstname
to
p_country
must each appear exactly once in the
order:
p_firstname
p_lastname
p_address
p_city
p_country
<xs:element name="p_record"> <xs:complexType> <xs:sequence> <xs:element name="p_firstname" type="xs:string"/> <xs:element name="p_lastname" type="xs:string"/> <xs:element name="p_address" type="xs:string"/> <xs:element name="p_city" type="xs:string"/> <xs:element name="p_country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
This example illustrating the use of the xs:sequence
element
is taken from the "patient" schema:
<xs:element name = "patient"> <xs:complexType> <xs:sequence> <xs:element ref = "name" minOccurs = "0"></xs:element> <xs:element ref = "sex"></xs:element> <xs:element ref = "born" minOccurs = "0"></xs:element> <xs:element ref = "address" minOccurs = "0"></xs:element> <xs:element ref = "occupation" minOccurs = "0"></xs:element> <xs:element ref = "insurance" minOccurs = "0"></xs:element> <xs:element ref = "nextofkin" minOccurs = "0"></xs:element> <xs:element ref = "submitted"></xs:element> <xs:element ref = "examination" minOccurs = "0" maxOccurs = "unbounded"></xs:element> <xs:element ref = "therapy" minOccurs = "0"></xs:element> <xs:element ref = "result" minOccurs = "0"></xs:element> <xs:element ref = "remarks" minOccurs = "0" maxOccurs = "unbounded"></xs:element> </xs:sequence> <xs:attribute name = "ID" type = "xs:string"></xs:attribute> </xs:complexType> </xs:element>
It shows a sequence with a list of optional elements and two required
elements, i.e. sex
and
submitted
.