Hello,
you can simulate an if by 2 where expressions
according the approach described below.
Best regards
Walter
if (booleanExpression)
then (expression1)
else (expression2)
is equivalent to Tamino XQuery
let $condition := (booleanExpression)
return (
let $d := “then”
where $condition
return (expression1),
let $d := “else”
where not($condition)
return (expression2),
)
If the conditional expression is not contained in filter or sort expression (it is independent of the context item) then a simpler expression can be used:
let $condition := (booleanExpression)
return ( (expression1)[$condition], (expression2) [not($condition)] )
Example
? W3C XQuery
if (input()/cruise[price = 1088])
then ( )
else ( )
? Tamino XQuery 4
let $condition := (input()/cruise[price = 1088])
return
(let $d := “then”
where $condition
return ,
let $d := “else”
where not($condition)
return )
more simpler case
? W3C XQuery
if (count($b/author) > 2)
then
else ()
? Tamino XQuery 4
let $a:= “then”
where (count($b/author) > 2)
return
#Tamino#API-Management#webMethods