Latest web development tutorials

XML Schema องค์ประกอบยูเนี่ยน

XML Schema อ้างอิง XML Schema สมบูรณ์อ้างอิง

ความหมายและการใช้งาน

องค์ประกอบสหภาพ simpleType กำหนดส่วนใหญ่ของคอลเลกชันที่กำหนดไว้

องค์ประกอบข้อมูล

  • องค์ประกอบหลัก: simpleType

ไวยากรณ์

<union
id=ID
memberTypes="list of QNames"
any attributes
>

(annotation?,(simpleType*))

</union>

(ใช่หรือไม่ลงบอกว่าองค์ประกอบที่สามารถเกิดขึ้นได้เป็นศูนย์หรือครั้งหนึ่งในองค์ประกอบของสหภาพ.)

属性 描述
id 可选。规定该元素的唯一的 ID。
memberTypes 可选。规定在 schema 中定义的内置数据类型或 simpleType 元素的名称列表。
any attributes 可选。规定带有 non-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: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 อ้างอิง XML Schema สมบูรณ์อ้างอิง