XML Schema union 元素
完整 XML Schema 參考手冊(cè)
定義和用法
union 元素定義多個(gè) simpleType 定義的集合。
元素信息
語法
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType*))
</union>
(? 符號(hào)聲明在 union 元素中該元素可出現(xiàn)零次或一次。)
屬性 | 描述 |
id | 可選。規(guī)定該元素的唯一的 ID。 |
memberTypes | 可選。規(guī)定在 schema 中定義的內(nèi)置數(shù)據(jù)類型或 simpleType 元素的名稱列表。 |
any attributes | 可選。規(guī)定帶有 non-schema 命名空間的任何其他屬性。 |
實(shí)例 1
本例是一個(gè)合并了兩個(gè)簡(jiǎn)單類型的簡(jiǎn)單類型:
<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>
完整 XML Schema 參考手冊(cè)
更多建議: