Schemat XML wszystkie elementy
❮ Pełne odniesienie do schematu XML
Definicja i użycie
Element all określa, że elementy podrzędne mogą pojawiać się w dowolnej kolejności i że każdy element podrzędny może wystąpić zero lub jeden raz.
Informacje o elemencie
- Elementy nadrzędne: group, complexType, restrykcje (zarówno simpleContent, jak i complexContent), rozszerzenie (zarówno simpleContent, jak i complexContent)
Składnia
<all
id=ID
maxOccurs=1
minOccurs=0|1
any attributes
>
(annotation?,element*)
</all>
(Znak ? deklaruje, że element może wystąpić zero lub jeden raz, a znak * oznacza, że element może wystąpić zero lub więcej razy wewnątrz elementu all)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
maxOccurs | Optional. Specifies the maximum number of times the element can occur. The value must be 1. |
minOccurs | Optional. Specifies the minimum number of times the element can occur. The value can be 0 or 1. Default value is 1 |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
Przykład 1
<xs:element name="person">
<xs:complexType>
<xs:all>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
Powyższy przykład wskazuje, że elementy „firstname” i „lastname” mogą pojawiać się w dowolnej kolejności, ale oba elementy MUSZĄ wystąpić raz i tylko raz!
Przykład 2
<xs:element name="person">
<xs:complexType>
<xs:all>
<xs:element name="firstname" type="xs:string" minOccurs="0"/>
<xs:element name="lastname" type="xs:string" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
Powyższy przykład wskazuje, że elementy „firstname” i „lastname” mogą pojawiać się w dowolnej kolejności i każdy element MOŻE pojawić się zero lub jeden raz!
❮ Pełne odniesienie do schematu XML