Элемент последовательности схемы XML
❮ Полный справочник по XML-схеме
Определение и использование
Элемент sequence указывает, что дочерние элементы должны появляться в последовательности. Каждый дочерний элемент может встречаться от 0 до любого количества раз.
Информация об элементе
- Родительские элементы: группа, выбор, последовательность, complexType, ограничение (как simpleContent, так и complexContent), расширение (как simpleContent, так и complexContent)
Синтаксис
<sequence
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
(Знак ? указывает, что элемент может встречаться ноль или один раз внутри элемента последовательности)
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 |
Пример 1
В этом примере показано объявление для элемента с именем «personinfo», который должен содержать следующие пять элементов по порядку; «имя», «фамилия», «адрес», «город» и «страна»:
<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>
Пример 2
В этом примере показано объявление элемента с именем «pets», который может содержать ноль или более следующих элементов, dog и cat, в элементе sequence:
<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>
❮ Полный справочник по XML-схеме