您现在的位置: 365建站网 > 建站教程 > Schema 教程 > XML Schema choice 元素

XML Schema choice 元素

此节有 243 人学习过     参与评论

定义和用法

XML Schema 的 choice 元素仅允许包含在 <choice> 声明中的元素之一出现在包含元素中。

元素信息

出现次数 在 group 和 complexType 元素中为一次;其他为无限制。
父元素 group、choice、sequence、complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)
内容 annotation、any、choice、element、group、sequence

语法

<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>

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

</choice>

(? 符号声明在 choice 元素中,元素可出现零次或一次,* 符号声明元素可出现零次或多次。)

属性 描述
id 可选。规定该元素的唯一的 ID。
maxOccurs 可选。规定 choice 元素在父元素中可出现的最大次数。该值可以是大于或等于零的整数。若不想对最大次数设置任何限制,请使用字符串 "unbounded"。 默认值为 1。
minOccurs 可选。规定 choice 元素在父元素中可出现的最小次数。该值可以是大于或等于零的整数。若要指定该 any 组是可选的,请将此属性设置为零。 默认值为 1。
any attributes 可选。规定带有 non-schema 命名空间的任何其他属性。

实例

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

上面的例子定义 "person" 元素必须包含一个 "employee" 元素或一个 "member" 元素。

如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛

发表评论 (243人查看0条评论)
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
昵称:
最新评论
------分隔线----------------------------
Schema 教程目录

快速入口

· 365软件
· 杰创官网
· 建站工具
· 网站大全

其它栏目

· 建站教程
· 365学习

业务咨询

· 技术支持
· 服务时间:9:00-18:00
365建站网二维码

Powered by 365建站网 RSS地图 HTML地图

copyright © 2013-2024 版权所有 鄂ICP备17013400号