Check If Set of Nodes are Equal to Each Other XPath 1.0
<p>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,</p>

<pre><code>&lt;a&gt;
    &lt;b-token&gt;123456789&lt;/b-token&gt;
    ...
    &lt;c&gt;
        &lt;d&gt;
            &lt;d-token&gt;123456789&lt;/d-token&gt;
            ...
        &lt;/d&gt;
        &lt;e&gt;
            &lt;e-token&gt;123456789&lt;/e-token&gt;
            ...
        &lt;/e&gt;
        &lt;f&gt;
            &lt;f-token&gt;123456789&lt;/f-token&gt;
            ...
        &lt;/f&gt;
    &lt;c&gt;
&lt;/a&gt;
</code></pre>

<p>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?</p>

<p>Here is an example XPath that I though would have worked, but it doesn't </p>

<pre><code>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']";
</code></pre>

<p>It works when I put a specific value after the '=' like so:</p>

<pre><code>String xpathExpression = "/descendant-or-self::node()/*[substring(name(), string-length(name() ) - (string-length('token')-1) ) = 'token'] = '123456789'";
</code></pre>

<p>I am using Java 7 if it matters.</p>

<p>Thanks</p>