XML Schema union 元素
❮ 完整的 XML Schema 参考
定义和用法
union 元素定义了一个简单类型,它是由指定简单数据类型的值组成的集合(并集)。
元素信息
- 父元素: simpleType
语法
<union
id=ID
memberTypes="list of QNames"
任何属性
>
(annotation?,(simpleType*))
</union>
(问号 (?) 表示该元素可以在 union 元素内出现零次或一次)
Attribute | 描述 |
---|---|
id | 可选。指定元素的唯一 ID |
memberTypes | 可选。指定一个内置数据类型或在模式中定义的 simpleType 元素的列表。 |
any attributes | 可选。指定任何其他非 schema 命名空间的属性 |
示例 1
此示例显示了一个由两个简单类型组成的并集简单类型。
<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:restriction>
<xs:restriction base="xs:string">
</xs:simpleType>
<xs:simpleType name="sizebystring">
<xs:enumeration value="small"/>
</xs:restriction>
</xs:simpleType>
❮ 完整的 XML Schema 参考