Part 3 of XPath Location Steps: Predicates

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 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.



Inside XSLT
Inside Xslt
ISBN: B0031W8M4K
EAN: N/A
Year: 2005
Pages: 196

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net