To do an OR
on two different nodes, I can do the following:
//C:Year[not(@value="2019")] | //R:Year[not(@value="2019")]
However, if there is a long expression, this becomes a bit unwieldy, especially if there are more than 2 ORs. Is there a way to do something like the following:
//(C:Year or R:Year)[not(@value="2019")]
Basically, is it possible rather than evaluate the full axis-node-predicate
expression and OR-ing the full thing, to be able to put an OR
within the node test itself.
This (only) works in XPath 2.0+
But, unfortunately, not in XPath 1.0.
The W3C XPath 1.0 language reference states under 3.1:
However
/steps/
(*StepExpr
) are not mentioned.But the XPath 2.0 ref states:
With this hint I came up with this query that also works in XPath 1.0:
So, v2+ is more flexible but the same principle applies. Gustafson, M. Kay, and others discussed an XPath 2.0 bug long this lines leading to Errata XP.E3. D. Chamberlin: