XML Schema union 요소
정의와 사용법
union 요소는 여러 simpleType 정의의 집합을 정의합니다.
요소 정보
출현 횟수 | 한 번 |
부요소 | simpleType |
내용 | annotation, simpleType |
문법
<union id=ID memberTypes="list of QNames" any attributes > (annotation?,(simpleType*)) </union>
(? 기호는 union 요소에서 이 요소가 0회나 1회만 등장할 수 있음을 나타냅니다。)
속성 | 설명 |
---|---|
id | 선택 사항. 이 요소의 독특한 ID를 정의합니다. |
memberTypes | 선택 사항. schema에서 정의된 내장 데이터 타입이나 simpleType 요소의 이름 목록을 정의합니다. |
any attributes | 선택 사항. non-schema 이름 공간을 가진 다른 어떤 속성도 정의합니다. |
예제
예제 1
이 예제는 두 간단한 타입을 병합한 간단한 타입입니다:
<xs:element name="jeans_size"> <xs:simpleType> <xs:union memberTypes="sizebyno sizebystring" /> </xs:simpleType> </xs:element> <xs:simpleType name="sizebyno"> <xs:restriction base="xs:positiveInteger"> <xs:maxInclusive value="42"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="sizebystring"> <xs:restriction base="xs:string"> <xs:enumeration value="small"/> <xs:enumeration value="medium"/> <xs:enumeration value="large"/> </xs:restriction> </xs:simpleType>