SetExpr

Select the union or intersection of node sets.


Syntax

SetExpr

graphics/SetExpr.jpg

Description

With a SetExpr you can select the union or intersection of node sets. A union set is constructed by using the operator | and contains all nodes that are in any one of the node sets. An intersection is constructed by using the operator intersect and contains only those nodes that are in all nodes.

Compatibility

It corresponds to the expression UnionExpr defined in XPath, Section 3.3, Rule 18. However, X-Query adds the intersect operator which is not present in XPath.

Examples

  • Select the union of all medication descendants and diagnosis descendants of patients:

    /patient//medication | /patient//diagnosis
  • Select the intersection of all patients born in 1950 and patients with medication in tablet form among all male patients:

    /patient[born=1950] intersect /patient[//medication/type[@form='tablet']] intersect /patient[sex ~= 'male']
  • Certainly, you can write this query easier, for example:

    /patient[born=1950 and .//medication/type[@form='tablet'] and sex ~= 'male']

Related Expressions

Location Path PrimaryExpr Predicate