Select a set of nodes along a path.
Starting from a given point in a document tree, a PathExpr
selects a node-set by following a location path. A path expression can be one
of the following:
a location path, selecting a set of nodes by following location steps, starting either at the document root (absolute location path) or at the context node (relative location path),
a filter expression selecting a set of nodes e.g. as a result to a function call or an expression enclosed in parentheses, possibly followed by one or more predicates,
a filter expression followed by the path operator /
,
followed by a relative location path which starts with the set of nodes
resulting from the filter expression,
a filter expression followed by the path operator //
,
followed by a relative location path which starts anywhere inside the set of
nodes resulting from the filter expression
It corresponds to the expression PathExpr
defined in XPath,
Section 3.3, Rule
19.
Select all patients (a relative LocationPath
starting at
the context node which is the doctype element node patient
in our
example):
patient
Select the answer to all questions (a simple FilterExpr
can be just a PrimaryExpr
which is basically an expression without
operator such as a Number
):
42
Get the number of all patients (a FilterExpr
that
identifies a node-set which results from calling the standard XPath function
count()
with all patient
nodes as argument):
count(patient)
Get the number of all patients who died (a FilterExpr
that identifies a node-set which results from calling the standard XPath
function count()
; the argument is the set of all
patient
nodes that have a descendant node
deceased
):
count(patient[//deceased])
Select the names of all doctors who have discharged patients or had to
register a patient's death provided that the doctor's surname begins with
"G" (a FilterExpr
enclosed in a
parenthesized PrimaryExpr
followed by a Predicate
:
select the union of the set of any descendant result/discharged
nodes and result/deceased
nodes; from this node set select all
descendant name
nodes that have an immediate child element node
surname
whose value contains a word beginning with
"G"):
((//result/discharged | //result/deceased)//name)[surname ~= 'G*']
Location
Path |
FilterExpr |
SetExpr |