Tamino XML Server Version 9.7
 —  XQuery 4 Reference Guide  —

IfExpr

Conditional expression based on if, then, and else.


Syntax

IfExpr

graphics/IfExpr.png

Expr Expr Expr

Top of page

Description

An IfExpr implements a conditional expression. The expression following the if keyword is called the test expression, the expression following the then keyword is called the then-expression and the final one is called the else-expression. If the effective boolean value of the test expression is true, then the value of the then-expression is returned, otherwise the value of the else-expression is returned.

In contrast to other languages the else-expression is mandatory. If you do not need the else-expression, you can return an empty string, or a NaN value if you need a numerical value.

Top of page

Example

Top of page

Related Syntax Constructs

The following construct(s) refer to this construct:

Top of page