34.5. unions
34.5.1. 개요 링크 복사링크가 클립보드에 복사되었습니다!
XML 스키마에서 공용 구조체는 여러 단순 형식 중 하나일 수 있는 형식을 설명할 수 있는 구문입니다.In XML Schema, a union is a construct that allows you to describe a type whose data can be one of a number of simple types. 예를 들어 값이 정수 1이거나 첫 번째 문자열에 해당하는 형식을 정의할 수 있습니다.For example, you can define a type whose value is either the integer 1 or the string first. 공용 구조체는 Java Strings에 매핑됩니다.
34.5.2. XML 스키마로 정의 링크 복사링크가 클립보드에 복사되었습니다!
XML Schema unions는 simpleType 요소를 사용하여 정의됩니다. Union의 멤버 유형을 정의하는 최소 하나의 union 요소를 포함합니다. 멤버 형식 공용 구조체는 공용 구조체의 인스턴스에 저장할 수 있는 유효한 데이터 형식입니다.The member types of the union are the valid types of data that can be stored in an instance of the union. union 요소의 memberTypes 특성을 사용하여 정의됩니다. memberTypes 특성 값은 하나 이상의 정의된 단순 형식 이름 목록을 포함합니다. 예 34.13. “간단한 통합 유형” 정수 또는 문자열을 저장할 수 있는 공용 구조체의 정의를 보여 줍니다.Shows the definition of a union that can store either an integer or a string.
예 34.13. 간단한 통합 유형
<simpleType name="orderNumUnion"> <union memberTypes="xsd:string xsd:int" /> </simpleType>
<simpleType name="orderNumUnion">
<union memberTypes="xsd:string xsd:int" />
</simpleType>
명명된 형식을 결합의 멤버 유형으로 지정하는 것 외에도 무명 간단한 유형을 union의 멤버 유형으로 정의할 수도 있습니다.In addition to specifying named types as a member type of a union, you can also define an anonymous simple type as a member type of a union. 이는 union 요소 내에 anonymous 유형 정의를 추가하여 수행됩니다. 예 34.14. “익명 회원 유형(Anonymous Member type)” 유효한 정수의 가능한 값을 1에서 10까지 제한하는 익명 멤버 형식이 포함된 통합의 예를 보여줍니다.
예 34.14. 익명 회원 유형(Anonymous Member type)
34.5.3. Java로의 매핑 링크 복사링크가 클립보드에 복사되었습니다!
XML Schema union 유형은 Java String 개체에 매핑됩니다. 기본적으로 Apache CXF는 생성된 오브젝트의 내용을 확인하지 않습니다. Apache CXF의 유효성을 검사하려면 “facet 강제” 에 설명된 대로 스키마 유효성 검사를 사용하도록 런타임을 구성해야 합니다.