当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema sequence 元素
The sequence element specifies that the child elements must appear in a sequence. Each child element can occur from 0 to any number of times.
sequence元素指明了子元素必须在一个序列中出现。每个子元素出现的次数任意(包括0次)。
<sequence id=ID maxOccurs=nonNegativeInteger|unbounded minOccurs=nonNegativeInteger any attributes > (annotation?,(element|group|choice|sequence|any)*) </sequence> |
(The ? sign declares that the element can occur zero or one time inside the sequence element)
“?”符号用于声明元素可以出现的次数(0次或1次)
属性 | 描述 |
---|---|
id | Optional. Specifies a unique ID for the element 可选参数。为元素指定一个独立的ID |
maxOccurs | Optional. Specifies the maximum number of times the sequence element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value "unbounded". Default value is 1 可选参数。指定序列元素在父类元素中允许出现的最大次数。这个值可以是大于等于0的任何值。如果你希望设置为无限大,可以使用“unbounded”。默认值是1 |
minOccurs | Optional. Specifies the minimum number of times the sequence element can occur in the parent element. The value can be any number >= 0. Default value is 1 可选参数。指定序列元素在父类元素中允许出现的最小次数。这个值可以是大于等于0的任何值。默认值是1 |
any attributes | Optional. Specifies any other attributes with non-schema namespace 可选参数。指定其它的属性(这些属性无schema命名空间) |
This example shows a declaration for an element called "personinfo", which must contain the following five elements in order; "firstname", "lastname", "address", "city", and "country":
这个案例展示了名为“personinfo”的元素声明,它必须按顺序包含下列5个元素:"firstname"、"lastname"、"address"、"city"以及"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> |
This 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:
这个案例展示了一个名为“pets”的元素声明,该元素可以在sequence[序列]属性中包含0个或多个下列元素:dog和cat:
<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> |