Predicates are used to filter node sets selected in the node test. Predicates are placed in square brackets following a node test. Multiple steps in a location path may have predicates.
Predicates can be relatively simple, such as
child::para[position()=1], which returns the first
para child of the context node. They can also be fairly complicated, such as:
which returns the second
section of the fifth
chapter of the
doc document element.
There are several example XSLT files in XPath/Demos that illustrate how XPath works. Take a moment to run through these examples by transforming XPath/Demos/Beatles.xml against each. They include: