Define keyref selector based on element type in XPath
- by Robert Sirre
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?