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

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

Schema (XSD) 中的 XML Schema choice 元素


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

Definition and Usage
定义和用法

XML Schema choice element allows only one of the elements contained in the <choice> declaration to be present within the containing element.
XML Schema choice 元素允许使用通过<choice>声明的嵌套元素中一个元素。

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
语法

<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>

(The ? sign declares that the element can occur zero or one time, and the * sign declares that the element can occur zero or more times inside the choice element)
“?”符号用于声明元素可以出现的次数(0次或1次),“*”符号用于声明元素可以在choice元素中出现的次数(0次或多次)。

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
maxOccurs Optional. Specifies the maximum number of times the choice 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
可选参数。指定choice元素在父类元素中出现的最大次数。其值可以大于等于0;或者,如果你不希望对最大值进行限制,可以使用“unbounded”。默认值是1
minOccurs Optional. Specifies the minimum number of times the choice element can occur in the parent the element. The value can be any number >= 0. Default value is 1
可选参数。指定choice元素在父类元素中出现的最小次数。其值可以大于等于0。默认值是1
any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定非schema命名空间的其它属性

Example 1
案例1

<xs:element name="person"> <xs:complexType> <xs:choice> <xs:element name="employee" type="employee"/> <xs:element name="member" type="member"/> </xs:choice> </xs:complexType>
</xs:element>

The example above defines an element named "person" which must contain either a "employee" element or a "member" element.
上述案例定义了一个名为“person”的元素,它必须包含一个“employee”元素或一个“member”元素。

评论 (0) All

登陆 | 还没注册?