Reputation: 53
Using XSD 1.1 is it possible to assert that an attribute exists somewhere else.
Example:
<root>
<someelement>
<lookup name="test"/>
<bla>
<lookup name="tbl2"/>
<morebla>
<evenmore>
<lookup name="tbl2"/>
</evenmore>
</morebla>
</bla>
</someelement>
<table name="test">
...
</table>
<table name="tbl2">
...
</table>
</root>
How would I assert that the element lookup has a name that is used in an table element?
The assert would need to be on the root element since it's not possible to assert up the element tree, but how would I assert on every lookup element regardless of where it is in the document structure?
Upvotes: 0
Views: 345
Reputation: 6016
Have in mind that in XPath 2.0 comparing $s1 = $sequence2
returns true if and only if $s1
(or any of its elements if it is a sequence) exists in $sequence2
. So you can use this simple XPath test for your assert:
every $lookupName in descendant-or-self::lookup/@name satisfies $lookupName = descendant-or-self::table/@name
Upvotes: 1