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

Schema (XSD)
Schema (XSD) 介绍
为何使用 XML Schemas?
如何定制 XSD
XSD - <schema>元素
XSD 简单元素
XSD 属性
XSD 约束面
XSD 复合元素
XSD 复合空元素
XSD 复合纯元素
XSD 复合纯文本
XSD 混合内容的复合类型
XSD 指示器复合类型
XSD <any> 元素
XSD <anyAttribute> 元素
XSD 元素替代
XSD 实例
XSD 字符串数据类型
XSD 日期数据类型
XSD 小数数据类型

Schema (XSD) 中的 XML Schema union 元素


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

Definition and Usage
定义和用法

The union element defines a simple type as a collection (union) of values from specified simple data types.
union元素的作用是:定义一个作为具体单独数据类型值的集合(或组合)的简单类型值。

Element Information
元素信息

  • Parent elements: simpleType
    父类信息:simpleType[简单类型]

Syntax
语法

<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType*))
</union>

(The ? sign declares that the element can occur zero or one time inside the union element)
“?”符号用于声明元素在union元素中允许出现的次数(0次或1次)

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
memberTypes Optional. Specifies a list of built-in data types or simpleType elements defined in a schema
可选参数。指定一个内置数据类型列表,或是在一个schema元素中定义的simpleType[简单类型]元素
any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定非schema命名空间的其它属性

Example 1
案例1

This example shows a simple type that is a union of two simple types:
这个案例展示了一个简单类型值,它是两个简单类型的组合:

<xs:element name="jeans_size"> <xs:simpleType> <xs:union memberTypes="sizebyno sizebystring" /> </xs:simpleType>
</xs:element>
<xs:simpleType name="sizebyno"> <xs:restriction base="xs:positiveInteger"> <xs:maxInclusive value="42"/> </xs:restriction>
</xs:simpleType>
<xs:simpleType name="sizebystring"> <xs:restriction base="xs:string"> <xs:enumeration value="small"/> <xs:enumeration value="medium"/> <xs:enumeration value="large"/> </xs:restriction>
</xs:simpleType>

评论 (0) All

登陆 | 还没注册?