Elemen pilihan Skema XML
Referensi Skema XML Lengkap
Definisi dan Penggunaan
Elemen pilihan Skema XML memungkinkan hanya satu elemen yang terkandung dalam deklarasi <choice> untuk ada di dalam elemen yang memuatnya.
Informasi Elemen
- Elemen induk: grup, pilihan, urutan, complexType, pembatasan (baik simpleContent dan complexContent), ekstensi (baik simpleContent dan complexContent)
Sintaksis
<choice
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</choice>
(Tanda ? menyatakan bahwa elemen dapat muncul nol atau satu kali, dan tanda * menyatakan bahwa elemen dapat muncul nol atau lebih kali di dalam elemen pilihan)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
maxOccurs | Optional. Specifies the maximum number of times the choice 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 choice element can occur in the parent the element. The value can be any number >= 0. Default value is 1 |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
Contoh
<xs:element name="person">
<xs:complexType>
<xs:choice>
<xs:element name="employee" type="employee"/>
<xs:element name="member" type="member"/>
</xs:choice>
</xs:complexType>
</xs:element>
Contoh di atas mendefinisikan elemen bernama "orang" yang harus mengandung elemen "karyawan" atau elemen "anggota".
Referensi Skema XML Lengkap