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