当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema sequence 元素

Schema (XSD)
XSD 逻辑值数据类型
XML Schema总结
XML Schema 参考
XSD 验证

Schema (XSD) 中的 XML Schema sequence 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 308 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

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次)。

Element Information
元素信息

  • Parent elements: group, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
    父类元素:group[组]、choice[选择]、sequence[序列]、complexType[复合类型]、restriction[限制] (包括simpleContent[单一内容]和complexContent[复合内容])以及extension[扩展] (包括simpleContent[单一内容]和complexContent[复合内容])

Syntax
语法

<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命名空间)

Example 1
案例1

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>

Example 2
案例2

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>

评论 (0) All

登陆 | 还没注册?