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.
The following expression is a single statement expression:
concat("Hello"," ",$input.n1)
The following notes explain the parts of this expression:
•concat is a function that joins two or more values into a single string.
•"hello", " "$input.n1 are the parameters of the function concat.
- "hello" is a string. Always include a string within quotes. You may use single or double quotes. However, ensure that you use the same style within an expression.
- n1 is an input variable. When you add it to an expression, the Expression Editor converts it to $input.n1. Always prefix a variable with a $. Do not add quotes around variables.
- The parameter " " denotes space.
•Include parameters within parentheses.
•Separate parameters with commas.
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:
•First, you declare the variables $n1 and $n2. Use the operator := to assign a value.
Note: Even if you defined $n1 and $n2 as integers in an Assignment step, you must declare them as numbers in the Expression Editor.
•You can use XQuery keywords such as let, if, then, and else. They are case sensitive.
Important: If you start an expression with the keyword let, you must end the expression with the keyword return.
•We use the Expression Editor to define the value of a third variable $r1 using the following rules:
- If the value of $n1 is greater than the value of $n2, $r1 takes the value: Greater: N1 > N2.
- If the value of $n1 is less than the value of $n2, $r1 takes the value: Less: N1 < N2.
- If the values of $n1 and $n2 are the same, $r1 takes the value: Same.
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