Predicates
A predicate consists of an expression, called a predicate expression, that is enclosed in square brackets ([]). A predicate filters a sequence by retaining some items and discarding others.
The predicate expression is evaluated once for each item
in the sequence. The result of the predicate expression is an xs:boolean value
called the predicate truth value. Those items for which
the predicate truth value is true are retained, and those for which
the predicate truth value is false are discarded. The value of the
predicate expression must not be a numeric value. For all other data
types, the predicate truth value is the effective boolean value of
the predicate expression. The effective boolean value is false if
the predicate expression evaluates to an empty sequence or false.
Otherwise, the effective boolean value is true.
Examples
descendant::phone[attribute::type = "work"]selects all the descendants of the context node that are elements namedphoneand whose type attribute has the value "work".child::address[prov-state][pcode-zip]selects all theaddresschildren of the context node that have aprov-statechild element and apcode-zipchild element.