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 positionfor example, PLANET[3] is true if and only if PLANET[position() = 3] is true.
The predicate contains XPath expressions of the kind youve seen throughout this chapter: rarely those that return node sets, mostly those that return strings, numbers , or Boolean values. For example, the location path preceding -sibling::MASS[position() = 4] selects the fourth previous <MASS> sibling element of the context node.