XML Schema all 요소

정의와 사용법

all 요소는 자식 요소가 어떤 순서로든 출현할 수 있음을 정의하며, 각 자식 요소는 0회나 1회만 출현할 수 있습니다.

요소 정보

출현 횟수 한 번
부모 요소 group, restriction (simpleContent), extension (simpleContent), restriction (complexContent), extension (complexContent), complexType
내용 annotation, element

문법

<all
id=ID
maxOccurs=1
minOccurs=0|1
any attributes
>
(annotation?,element*)
</all>

(? 기호는 이 요소가 0회나 1회만 출현할 수 있음을, * 기호는 이 요소가 모든 요소 중에서 0회나 여러 번 출현할 수 있음을 나타냅니다。)

속성 설명
id 선택 사항. 이 요소의 유일한 식별자.
maxOccurs 선택 사항. 요소가 출현할 수 있는 최대 횟수. 이 값은 1이어야 합니다.
minOccurs 선택 사항. 요소가 출현할 수 있는 최소 횟수. 이 값은 정수 0 또는 1일 수 있습니다. 요소가 선택 사항인지 지정하려면, 이 속성을 0으로 설정합니다. 기본 값은 1입니다.
any attributes 선택 사항. non-schema 이름 공간을 가진 다른 모든 속성을 정의합니다.

예제 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>

위의 예제는 "firstname"와 "lastname" 요소가 어떤 순서로든 출현할 수 있으며, 두 요소는 모두 한 번만 출현해야 하고, 출현할 수 없다!

예제 2

<xs:element name="person">
  <xs:complexType>
    <xs:all minOccurs="0">
      <xs:element name="firstname" type="xs:string"/>
      
    <xs:element name="lastname" type="xs:string"/>
  </xs:all>
</xs:complexType>

</xs:element>