Phần tử danh sách 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ử danh sách xác định một phần tử kiểu đơn giản là danh sách các giá trị của một kiểu dữ liệu được chỉ định.
Thông tin phần tử
- Phần tử chính: simpleType
Cú pháp
<list
id=ID
itemType=QName
any attributes
>
(annotation?,(simpleType?))
</list>
(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ử danh sách)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
itemType |
Specifies the name of a built-in data type or simpleType element defined in this or another schema. This attribute is not allowed if the content contains a simpleType element, otherwise it is required |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ví dụ 1
Ví dụ sau đây cho thấy một kiểu đơn giản là danh sách các số nguyên:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="intvalues" type="valuelist"/>
<xs:simpleType name="valuelist">
<xs:list itemType="xs:integer"/>
</xs:simpleType>
</xs:schema>
The "intvalues" element in a document could look like this (notice that
the list will have five list items):
<intvalues>100 34 56 -23 1567</intvalues>
Lưu ý: Khoảng trắng được coi là dấu phân tách mục danh sách!
Ví dụ 2
Ví dụ sau cho thấy một kiểu đơn giản là danh sách các chuỗi:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="stringvalues" type="valuelist"/>
<xs:simpleType name="valuelist">
<xs:list itemType="xs:string"/>
</xs:simpleType>
</xs:schema>
The "stringvalues" element in a document could look like this (notice
that the list will have four list items):
<stringvalues>I love XML Schema</stringvalues>
❮ Tham chiếu lược đồ XML hoàn chỉnh