Part 3 of XPath Location Steps: Predicates

The predicate in an XPath location step itself contains an XPath expression enclosed in brackets, [ and ]. The contained XPath expression is treated as if it evaluated to true or false. If it evaluates to a string, XPath treats it as true if the string is not empty. If it evaluates to a node set, XPath treats it as true if the node set is not empty. If it evaluates to a number, the overall result is considered true if that number matches the context position—for example, PLANET[3] is true if and only if PLANET[position() = 3] is true.

The predicate contains XPath expressions of the kind you’ve seen throughout this chapter: rarely those that return node sets, mostly those that return strings, numbers, ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.