Element sekwencji schematu XML
❮ Pełne odniesienie do schematu XML
Definicja i użycie
Element sekwencji określa, że elementy podrzędne muszą pojawić się w sekwencji. Każdy element podrzędny może wystąpić od 0 do dowolnej liczby razy.
Informacje o elemencie
- Elementy nadrzędne: grupa, wybór, sekwencja, complexType, ograniczenie (zarówno simpleContent, jak i complexContent), rozszerzenie (zarówno simpleContent, jak i complexContent)
Składnia
<sequence
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
(Znak ? deklaruje, że element może wystąpić zero lub jeden raz wewnątrz elementu sekwencji)
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 |
Przykład 1
Ten przykład przedstawia deklarację elementu o nazwie „personinfo”, który musi zawierać następujące pięć elementów w kolejności; „imię”, „nazwisko”, „adres”, „miasto” i „kraj”:
<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>
Przykład 2
Ten przykład pokazuje deklarację dla elementu o nazwie „pets”, który może mieć zero lub więcej z następujących elementów, pies i kot, w elemencie sekwencji:
<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>
❮ Pełne odniesienie do schematu XML