Phần tử trình tự 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ử trình tự chỉ định rằng các phần tử con phải xuất hiện trong một trình tự. Mỗi phần tử con có thể xuất hiện từ 0 đến bất kỳ số lần nào.
Thông tin phần tử
- Các phần tử chính: nhóm, lựa chọn, trình tự, complexType, hạn chế (cả Nội dung đơn giản và Nội dung phức tạp), tiện ích mở rộng (cả Nội dung đơn giản và Nội dung phức tạp)
Cú pháp
<sequence
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
(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ử trình tự)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
maxOccurs | Optional. Specifies the maximum number of times the sequence element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value "unbounded". Default value is 1 |
minOccurs | Optional. Specifies the minimum number of times the sequence element can occur in the parent element. The value can be any number >= 0. Default value is 1 |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
ví dụ 1
Ví dụ này cho thấy một khai báo cho một phần tử được gọi là "personinfo", phần tử này phải chứa năm phần tử sau theo thứ tự; "firstname", "lastname", "address", "city" và "country":
<xs:element name="personinfo">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Ví dụ 2
Ví dụ này hiển thị một khai báo cho một phần tử có tên "vật nuôi" có thể có 0 hoặc nhiều phần tử sau, chó và mèo, trong phần tử trình tự:
<xs:element name="pets">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="dog" type="xs:string"/>
<xs:element name="cat" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
❮ Tham chiếu lược đồ XML hoàn chỉnh