Given the following xml:
<parameterGroup>
<parameter value="1" name="Level0_stratum">
</parameter>
<parameter value="1" name="Level2_stratum">
</parameter>
<parameter value="1" name="Level1_stratum">
</parameter>
<parameter value="6" name="foo">
</parameter>
<parameter value="9" name="bar">
</parameter>
</parameterGroup>
I’d like to derive a boolean variable that indicates whether the @value of ALL the Level*_stratum values are the same, as in this case they are (1).
So far I’ve been able to group all the pertinent nodes in a set as follows:
select="//parameter[starts-with(@name,'Level') and ends-with(@name,'_stratum') ]"
but I’m not sure the most efficient way to compare all their @value attributes for equality?
I believe this should do what you’re looking to do (the
value-oflines are not necessary and are just there to show the values of the variables):When this is run on your sample input above, the result is:
When this is run on your sample input after changing the third
valueto 8 (or anything else), the result is: