Predicate

Contact Us or call 1-877-932-8228
Predicate

Predicate

axis::node_test[predicate]

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:

/child::doc/child::chapter[position()=5]/child::section[position()=2]

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:

  1. child.xsl
  2. childstar.xsl
  3. childtext.xsl
  4. attribute.xsl
  5. attributestar.xsl
  6. descendant.xsl
  7. self.xsl
Next