xml sequence


定义和用法
sequence 元素要求组中的元素以指定的顺序出现在包含元素中。每个子元素可出现 0 次到任意次数。

元素信息
出现次数 在组内为一次;否则为无限制。
父元素 group、choice、sequence、complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)
内容 annotation、any、choice、element、group、sequence

语法
<sequence
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>

(annotation?,(element|group|choice|sequence|any)*)

</sequence>(? 声明在 sequence 元素中该元素可出现零次或一次。)

属性 描述
id 可选。规定该元素的唯一的 ID。
maxOccurs 可选。规定 any 元素在父元素中可出现的最大次数。该值可以是大于或等于零的整数。若不想对最大次数设置任何限制,请使用字符串 "unbounded"。 默认值为 1。
minOccurs 可选。规定 any 元素在父元素中可出现的最小次数。该值可以是大于或等于零的整数。若要指定该 any 组是可选的,请将此属性设置为零。 默认值为 1。
any attributes 可选。规定带有 non-schema 命名空间的任何其他属性。
实例
例子 1
本例是一个针对 "personinfo" 元素的声明,该元素必需按顺序包含下列 5 个元素:"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>例子 2
本例是一个针对 "pets" 元素的声明,可包含零个或多个 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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值