RelativePathExpr

Select nodes on the relative path.

Top of page

Related Syntax Constructs

The following construct(s) refer to this construct:


Syntax

RelativePathExpr

graphics/RelativePathExpr.png

StepExpr AxisStep NoAxisStep

Description

A RelativePathExpr is a path expression consisting of a step expression that can be followed by one or more steps with or without axis. Starting from the context node, / separates location steps, while // is the abbreviated syntax for /descendant-or-self::node()/. If followed by an AxisStep, you can specify an abbreviated or unabbreviated step. Otherwise, you can specify a node test plus optional predicate expression.

Examples

  • Select all books written by Stevens:

    input()//book[author/last = "Stevens"]

    The relative path in the bracketed filter expression starts at the context node book and selects the author child node (a StepExpr), and then its child node last (a NoAxisStep).

  • Select all patients who have been treated with therapies including medication in the form of tablets:

    input()/patient[therapy//@form = "tablet"]

    The relative path in this expression starts at with therapy child nodes of patient elements and selects all descendant attribute nodes with the name form and value "tablet" (an abbreviated AxisStep).