Define keyref selector based on element type in XPath

Posted by Robert Sirre on Stack Overflow See other posts from Stack Overflow or by Robert Sirre
Published on 2010-03-13T14:14:59Z Indexed on 2010/03/13 14:25 UTC
Read the original article Hit count: 248

Filed under:
|
|

Let's say I have an XML file that will look like this:

<a>
    <b d="value1"/>
    <c d="value2"/>
</a>

In the XSD file that defines the structure of this XML file I defined the elements by name 'b' and 'c' to be of the same type (and the type requires attribute 'd').

Let's say that I want to make a keyReference of all elements of the type that both 'b' and 'c' are, is there any way in XPath to do this?

At the definition of the type of 'a' I would expect something like this:

<xs:keyref name="myReferenceName" refer="keyToReferTo">
    <xs:selector xpath="[@type='typenameof elements b and c?']"/>
    <xs:field xpath="@d"/>
</xs:keyref>

Is something like this possible, or is XPath, even in the XSD, schema-unaware?

© Stack Overflow or respective owner

Related posts about keyref

Related posts about xpath