2015-01-14 3 views
1

XML 스키마의 특성 값 조합을 제한 할 수 있습니까? 두 속성이있는 태그가 있으며 그 값의 조합을 허용하고 싶습니다. 예 : attribute_1에 값 "A"가있는 경우, attribute_2는 값 "B"를 가져서는 안됩니다.XML 스키마의 특성 값 제한

+0

관련 항목 : http://stackoverflow.com/questions/19734733/xml-schema-restricting-the-value-type-of-an-attirbute-based-on-the-type-of-anot?rq=1 – Thilo

답변

2

XSD 1.1에서는 assertions을 사용할 수 있습니다. (테스트되지 않은) 무언가 :

<xs:element name="SomeType"> 
    <xs:complexType> 
    <xs:attribute name="attribute_1" type="xs:string"> 
    <xs:attribute name="attribute_2" type="xs:string"/> 
    <xs:assert test="if (@attribute_1 = 'A') then @attribute_2 != 'B' else true()"/> 
    </xs:complexType> 
</xs:element> 

더 많은 예제 here을 참조하십시오.