Phần tử liên hợp lược đồ XML
❮ Tham chiếu lược đồ XML hoàn chỉnh
Định nghĩa và Cách sử dụng
Phần tử union định nghĩa một kiểu đơn giản là một tập hợp (kết hợp) các giá trị từ các kiểu dữ liệu đơn giản được chỉ định.
Thông tin phần tử
- Phần tử chính: simpleType
Cú pháp
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType*))
</union>
(Dấu? Khai báo rằng phần tử có thể xuất hiện không hoặc một lần bên trong phần tử union)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
memberTypes | Optional. Specifies a list of built-in data types or simpleType elements defined in a schema |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ví dụ 1
Ví dụ này cho thấy một kiểu đơn giản là sự kết hợp của hai kiểu đơn giả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>
❮ Tham chiếu lược đồ XML hoàn chỉnh