XSD identity restriction with node-set

I'm having problems creating an identity restriction due to a field evaluating the value of node -set in my instances.

Given the sample XML set:

<data>
    <Clusters>
        <Cluster FileID="0" Function="1">
            <Isotopes>
                <Isotope StickID="0"/>
                <Isotope StickID="1"/>
            </Isotopes>
        </Cluster>
        <Cluster FileID="0" Function="2">
            <Isotopes>
                <Isotope StickID="2"/>
            </Isotopes>
        </Cluster>
    </Clusters>
</data>

I am trying to create a constraint in such a way that for a given Isotope element, each combination of @StickID in combination with @FileID and @Function of the grandparent Cluster cluster must generate a unique key.

If from a data context, I define a selector in a cluster as follows:

<xs:key name="ClusterStickRefIdentity">
    <xs:selector xpath="Clusters"/>
    <xs:field xpath="Cluster/Isotopes/Isotope/@StickID"/>
    <xs:field xpath="@Function"/>
    <xs:field xpath="@FileID"/>
</xs:key>

As expected, an error occurs when checking an instance saying that the first field is evaluated as a node-set with more than one element, since the Isotopes element can contain an unlimited number of isotopic elements.

, , , node , ? , ?

+3

Source: https://habr.com/ru/post/1764632/


All Articles