允许所选组中包含的一个并且仅限一个元素出现在包含元素内。
<choice
id = ID
maxOccurs= (nonNegativeInteger | unbounded) : 1
minOccurs= nonNegativeInteger : 1
{any attributes with non-schema Namespace}...>
Content: (annotation?, (element | group | choice | sequence | any)*)
</choice>
特性
id
该元素的 ID。 id 值必须属于类型 ID 并且在包含该元素的文档中是唯一的。可选。
maxOccurs
可进行选择的最大次数。 该值可以是大于或等于零的整数。 若不想对最大次数设置任何限制,请使用字符串“unbounded”。 默认值为 1。可选。
minOccurs
可进行选择的最小次数。 该值可以是大于或等于零的整数。 若要指定该选项组是可选的,请将此属性设置为 zero。 默认值为 1。可选。
元素信息
出现次数 |
在 group 和 complexType 元素中为一次;其他为无限制。 |
父元素 |
group、choice、sequence、complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent) |
内容 |
annotation、any、choice、element、group、sequence |
示例
以下复杂类型定义一个元素,该元素具有一个属性,并且有一个且仅有一个元素来自四个指定元素的选择。
其他资源
有关更多信息,请参见“W3C XML Schema Part 1: Structures Recommendation”(W3C XML 架构第 1 部分:结构建议),网址为:www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-all。