Taskflows > The Expression Editor > Tips: Using XQuery 3.0 to create expressions
  

Tips: Using XQuery 3.0 to create expressions

Use XQuery version 3.0 to create expressions in the Expression Editor. The samples in this topic show you the syntax and the elements that you use to construct single statement and multi statement XQuery expressions.
For information about XQuery 3.0, see https://www.w3.org/TR/xquery-30/.

Single statement expression

The following expression is a single statement expression:
concat("Hello"," ",$input.n1)
The following notes explain the parts of this expression:
Assume that the value of $n1 is "World".
If you run:
concat("Hello", " ",$input.n1)
you get the following output:
Hello World

Multi-statement expression

The following expression is a multi-statement expression:

let $n1 := number($input.n1)
let $n2 := number($input.n2)

let $r1 := if ($n1 > $n2)
then "Greater: N1 > N2"
else if ($n1 < $n2)
then "Less: N1 < N2"
else "Same"
return $r1
The following notes explain the parts of this expression:
Assume that the value of $n1 is 20 and the value of $n2 is 250.
If you run:

let $n1 := number($input.n1)
let $n2 := number($input.n2)

let $r1 := if ($n1 > $n2)
then "Greater: N1 > N2"
else if ($n1 < $n2)
then "Less: N1 < N2"
else "Same"
return $r1
you get the following output:
Less: N1<N2
Here, $r1 now has the value
Less: N1<N2