XML Schema elementem sekwencji
Definicja i Wykorzystanie
Element sekwencja wymaga elementu grupy, aby określić kolejność ich wyświetlania w elemencie zawierającym. Każdy element podrzędny może wystąpić zero dowolną liczbę razy.
Element informacji
- Dominująca elementem group, wybór, sekwencja, complexType , ograniczenia (zarówno simpleContent i complexContent), rozbudowa (zarówno simpleContent i complexContent)
gramatyka
<sequence
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(element|group|choice|sequence|any)*)
</sequence>
(? Elementem komunikat w elemencie sekwencja może wystąpić zero lub jeden raz).
属性 | 描述 |
---|---|
id | 可选。规定该元素的唯一的 ID。 |
maxOccurs | 可选。规定 any 元素在父元素中可出现的最大次数。该值可以是大于或等于零的整数。若不想对最大次数设置任何限制,请使用字符串 "unbounded"。 默认值为 1。 |
minOccurs | 可选。规定 any 元素在父元素中可出现的最小次数。该值可以是大于或等于零的整数。若要指定该 any 组是可选的,请将此属性设置为零。 默认值为 1。 |
any attributes | 可选。规定带有 non-schema 命名空间的任何其他属性。 |
Przykład 1
Ten przykład jest oświadczenie przeciw "personinfo" element, element jest niezbędny zawiera następujące pięć elementów: "Book Nazwa", "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>
<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 jest oświadczenie dla "Zwierzęta" element może zawierać zero lub więcej elementów psów i kotów:
<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>
<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>
Kompletna XML Schema Reference