最上位の祖先タイプを条件とする子孫要素が必要です。その関係をxmlスキーマ1.0でモデル化することは可能ですか?もしそうなら、どのように?
以下は、私の望ましい構造/検証動作です。
<a1>
<b>
<c>
<d/> -- allowed if ancestor is a1
</c>
</b>
</a1>
<a2>
<b>
<c>
<d/> -- validation error - not allowed if ancestor is not a1
</c>
</b>
</a2>
XSD 1.1アサーションを使用すると、まさにそれが可能になるようですが、XMLスキーマ1.0に固執しています。
私は明らかに並列階層を作成し、d要素を1つだけに許可することができましたが、それは冗長で、スキーマのユーザーにとって混乱を招きます。
並列階層は次のようになります。
<a1>
<b1>
<c1>
<d/> -- allowed in c1 element
</c1>
</b1>
</a1>
<a2>
<b2>
<c2>
<d/> -- not allowed in c2
</c2>
</b2>
</a2>
編集:CMのヒントを使用して上記の質問に対するソリューションスキーマ
<xs:element name="a1">
<xs:complexType>
<xs:sequence>
<xs:element name="b" type="b1"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="a2">
<xs:complexType>
<xs:sequence>
<xs:element name="b" type="b2"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="b1">
<xs:sequence>
<xs:element name="c" type="c1"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="b2">
<xs:sequence>
<xs:element name="c" type="c2"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="c1">
<xs:sequence>
<xs:element name="d"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="c2">
<xs:sequence>
</xs:sequence>
</xs:complexType>