Select nodes based on position.
A SequenceExpr
consists either of a single
ProximityExpr
or of two or more proximity expressions that are
separated by the operators before
or after
. With
these operators you can select nodes based on sibling positioning.
The left operand of the before
or after
operator must be a set of sibling nodes and the right-hand operand must be an
element of this node-set (otherwise an empty node-set will be returned as a
result).
There is no SequenceExpr
in XPath. You can use the
operators before
and after
to simulate the XPath way
of selecting nodes along one of the axes preceding-sibling
or
following-sibling
, see the second and third example.
Select remarks to a patient (all descendant remarks
element nodes are sibling to some element node therapy
and
positioned after that node; in our example database this is true for only one
node; see also next example):
//remarks after therapy
Select street and housenumber of all patients' addresses (select all
element nodes that are child nodes of patient/address
and select
only those that in the document order of siblings are positioned before the
city
element):
/patient/address/* before city
Select all data of a patient except his or her name and any remarks
(from all immediate child element nodes of the patient
nodes
select the siblings following the name
node provided that they are
not the last one):
(/patient/* after name)[position() != last()]
Please note that you have to use the parentheses here. Otherwise the
predicate expression would be applied to the name
node and this
would yield an empty result set.
ProximityExpr |