Reputation: 2682
Is it possible to validate attribute values against element names in an XmlSchema. For e.g. For the XML fragment below, I want to ensure that the value in the 'thisShouldBeAnElementName' attribute should be an element name. So, valid values would be 'a','b' or 'c'.
<root>
<a/>
<b/>
<c thisShouldBeAnElementName='a'/>
</root>
Thanks.
Upvotes: 0
Views: 195
Reputation: 163352
In XSD 1.1 you can write an assertion:
<xs:element name="root">
...
<xs:assert test="every $a in .//@thisshouldbeanelementname
satisfies node-name($a) = .//*/node-name()"/>
...
</xs:element>
XSD 1.1 is currently implemented in Xerces and Saxon.
Upvotes: 1