0
상위 요소 (직접/간접) 요소의 특성에 a가있는 경우 요소의 특성이 특정 값을 가질 수있는 XSD 구조를 정의 할 수 있습니까? 어떤 가치?XSD - 상위 요소의 특성 값을 기준으로 특성 값 유효성 검사
예 :
<root>
<child1 myAttr="true">
<child2>
<child3 otherAttr="false" /> <!-- 'otherAttr' can only be 'false' if 'myAttr' is 'true' -->
</child2>
</child1>
</root>
의사 해결 방법 :
...을 'child3'복합 형의 정의 <rule condition="@otherAttr == true && //child1/@myAttr != false" />
처럼 뭔가를 추가하려면
예 :
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://My.Schema.Namespace"
targetNamespace="http://My.Schema.Namespace">
<xs:element name="root">
<xs:sequence>
<xs:element name="child1" type="child1Type" />
</xs:sequence>
</xs:element>
<xs:complexType name="child1Type">
<xs:sequence>
<xs:element name="child2" type="child2Type" />
</xs:sequence>
<xs:attribute name="myAttr" type="xs:boolean" use="optional" default="false" />
</xs:complexType>
<xs:complexType name="child2Type">
<xs:sequence>
<xs:element name="child3" type="child3Type" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="child3Type">
<xs:attribute name="otherAttr" type="xs:boolean" use="optional" default="true" />
<rule condition="@otherAttr == true && //child1/@myAttr != false" />
</xs:complexType>
같은 (http://stackoverflow.com/questions/ 것 2518384/xml-schema-to-restrict-one-field-on-another) – Dijkgraaf
해당 질문의 기본 사항은이 질문에 대한 답을 제공하지 못합니다. 비슷한 문제가 다른 요구 사항 및 세부 사항. 질문은 IMO에 서기에 충분히 독특합니다. – travega