Elemen urutan Skema XML
Referensi Skema XML Lengkap
Definisi dan Penggunaan
Elemen urutan menentukan bahwa elemen anak harus muncul dalam urutan. Setiap elemen anak dapat muncul dari 0 hingga beberapa kali.
Informasi Elemen
- Elemen induk: grup, pilihan, urutan, complexType, pembatasan (baik simpleContent dan complexContent), ekstensi (baik simpleContent dan complexContent)
Sintaksis
<sequence
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
(Tanda ? menyatakan bahwa elemen dapat muncul nol atau satu kali di dalam elemen urutan)
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 |
Contoh 1
Contoh ini menunjukkan deklarasi untuk elemen yang disebut "personinfo", yang harus berisi lima elemen berikut secara berurutan; "nama depan", "nama belakang", "alamat", "kota", dan "negara":
<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>
Contoh 2
Contoh ini menunjukkan deklarasi untuk elemen yang disebut "hewan peliharaan" yang dapat memiliki nol atau lebih elemen berikut, anjing dan kucing, dalam elemen urutan:
<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>
Referensi Skema XML Lengkap