RelationalExpr

Compare two values by using relational operators.


Syntax

RelationalExpr

graphics/RelationalExpr.jpg

Description

A RelationalExpr can be a simple AdditiveExpr or two or more AdditiveExpr expressions that are operands to one of the four relational operators < (less than), > (greater than), <= (less than or equal), and >= (greater than or equal). The comparison results in a Boolean value "true" or "false".

You can compare numeric values as well as string values, which are compared according to lexicographic ordering. If there is a collation defined for either of the operands or if both operands have the same collation defined, then the comparison is based on this collation, otherwise it is character-based.

Compatibility

It is compatible to the expression RelationalExpr defined in XPath, Section 3.4, Rule 24. However, in XPath RelationalExpr is restricted to comparison of numeric values.

In contrast to XSLT there is no need to use entity references for the "<" and ">", since the query string is not processed as an XML instance. But in XSLT a RelationalExpr appears as an attribute value and must therefore be referenced; the first example would look as follows: /patient/[born &lt; 1959].

Examples

  • Select the addresses of all patients whose surname is ordered before "Bl". The patient "Bloggs" is not in the result set, since "Bl" is positioned before "Bloggs" in the lexicographical order.

    /patient/address[../name/surname < 'Bl']
  • Check if the mortality rate is below 10% (check if the number of patient nodes multiplied by 10 is greater than the number of deceased nodes)

    count(/patient)*10 > count(//deceased)

Related Expressions

BetweenExpr EqualityExpr