제한 메커니즘을 사용한 복합 유형 파생
BizTak 편집기의 기능적인 면에서 볼 때 제한에 의한 파생은 확장에 의한 파생과 비슷합니다. 제한에 의해 파생된 복합 유형은 기본 데이터 유형과 비슷하지만 선언이 기본 데이터 유형의 선언보다 제한됩니다. 실제로 새 유형으로 나타내는 값은 단순 유형의 제한에서와 같이 기본 데이터 유형이 나타내는 값의 하위 집합입니다. 기본 데이터 유형의 값에 맞게 준비된 응용 프로그램은 제한된 유형의 모든 값을 성공적으로 처리할 수 있어야 합니다.
제한 메커니즘을 사용하여 새 복합 유형을 파생하는 포괄적인 방법을 보려면 W3C 웹 사이트를 참조하십시오. 이 웹 사이트 및 기타 웹 사이트에 대한 다양한 링크는 웹의 XSD 리소스를 참조하세요.
제한에 따라 복잡한 전역 형식에서 파생하려면 스키마 트리의 다른 위치에서 원하는 위치에 새 Record 노드를 삽입하는 것으로 시작합니다. 그런 다음 기본 데이터 형식 속성을 복합 전역 형식의 이름으로 설정합니다. 마지막으로 Derived By 속성의 설정을 기본값 인 Extension (적어도 기본 데이터 형식이 설정된 경우)에서 제한으로 변경합니다.
다음 예제에서 BillingAddress 는 새로 삽입된 레코드 노드의 이름이고 GlobalAddrType 은 파생되고 제한하려는 복합 전역 형식의 이름입니다. 스키마 트리 뷰에서 중복 노드 구조는 ShippingAddress 노드 아래의 인접 노드 구조와 동일한 BillingAddress라는 노드 아래에 표시됩니다. 둘 사이의 차이점은 BillingAddress 노드 구조에 기본 데이터 형식 GlobalAddrType에 대한 가능한 제한 사항이 적용되고 ShippingAddress 구조는 기본 데이터 형식 GlobalAddrType과 동일하게 유지된다는 것입니다.
기본 데이터 유형을 제한하도록 선택하였으므로 새 노드를 삽입할 수는 없지만 기존 노드의 속성을 변경하여 가능한 값 또는 동작을 더욱 제한할 수는 있습니다.
이전에는 Derived By 속성이여전히 Extension으로 설정되어 있습니다.
<xs:schema> <xs:element name="Root"> <xs:complexType> <xs:sequence> <xs:element name="ShippingAddress" type="GlobalAddrType" /> <xs:element name="BillingAddress"> <xs:complexType> <xs:complexContent mixed="false"> <xs:extension base="GlobalAddrType" /> </xs:complexContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="GlobalAddrType"> [Address structure defined globally here.] </xs:complexType> </xs:schema>
Derived By 속성을 확장에서 제한으로 전환한 후
<xs:schema> <xs:element name="Root"> <xs:complexType> <xs:sequence> <xs:element name="ShippingAddress" type="GlobalAddrType" /> <xs:element name="BillingAddress"> <xs:complexType> <xs:complexContent mixed="false"> <xs:restriction base="GlobalAddrType"> [Duplicate of address structure now appears here, ready to be restricted with additional attributes, set using the properties of the relevant nodes in the schema tree.] </xs:restriction> </xs:complexContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="GlobalAddrType"> [Address structure defined globally here.] </xs:complexType> </xs:schema>