0

目的:

私が作成しているスキーマでは、サブノードのインスタンスのスキーマ全体をチェックするのではなく、各親ノード内でのみ一意性をチェックする一意性制約が必要です。これは例で最もよく説明されていると思います。以下のxmlを参照してください。

問題:

私が使用している xpath は、 のすべてのインスタンスに対して一意性をチェックしますがの子である の<subnode value="x">インスタンスのみに対して一意性をチェックしたいと思います。<subnode value="x"><globalElement>

必要なエラーを含む XML:

<globalElement>
    <subnode value="1" />
    <subnode value="2" />
</globalElement>

<globalElement>
    <subnode value="1" />            <!-- Desired error here -->
    <subnode value="1" />            <!-- Desired error here -->
</globalElement>

XML と現在のエラー:

<globalElement>
    <subnode value="1" />           <!-- Error here -->
    <subnode value="2" />
</globalElement>

<globalElement>
    <subnode value="1" />            <!-- Error here -->
    <subnode value="1" />            <!-- Error here -->
</globalElement>

XML スキーマ (1.0):

<xs:element name="rootElement">
    <xs:complexType>
         <xs:choice minOccurs="0" maxOccurs="unbounded" >
             <xs:any namespace="##targetNamespace"  />
         </xs:choice>
    </xs:complexType>       
     <xs:unique name="name_check">
          <xs:selector xpath=".//prefix:globalElement/prefix:subnode" />
          <xs:field xpath="@value" />
     </xs:unique>
</element>
4

2 に答える 2