I want to use XPath to select a few nodes that end with the same word and check if they all equal one another. So, for example,
<a>
<b-token>123456789</b-token>
...
<c>
<d>
<d-token>123456789</d-token>
...
</d>
<e>
<e-token>123456789</e-token>
...
</e>
<f>
<f-token>123456789</f-token>
...
</f>
<c>
</a>
So, I want to search for all nodes ending in "-token" and make sure they are equivalent. Can this be done in XPath 1.0? 2.0? XSD?
Here is an example XPath that I though would have worked, but it doesn't
String xpathExpression = "/descendant-or-self::node()/*[substring(name(), string-length(name() ) - (string-length('token')-1) ) = 'token'] = /descendant-or-self::node()/*[substring(name(), string-length(name() ) - (string-length('token')-1) ) = 'token']";
It works when I put a specific value after the '=' like so:
String xpathExpression = "/descendant-or-self::node()/*[substring(name(), string-length(name() ) - (string-length('token')-1) ) = 'token'] = '123456789'";
I am using Java 7 if it matters.
Thanks