[XQuery] is it possible to put a condition in the return...

Hi,

Is someone know if it is possible to put a condition like “if…else…” in the “return” of XQuery 4. For exemple:


declare namespace tf='http://namespaces.softwareag.com/tamino/TaminoFunction' 
let $persons:=(for $Person in input()/Person 
where (tf:containsText($Person/Name ,'*for*')) 
return $Person/Name) 
return 
(if (count($persons) > 1000)
   <count>{count($persons)}</count>
 else 
   $persons
)

With Xquery 4 is it possible to make this or how I can do in another way?

Thank you for your help

C

Starting with Tamino 4.4 (due next month), if-then-else syntax will be supported. With Tamino 4.2, you can use a notation with filters:
if A then B else C
corresponds to e.g.
(B[A],C)[1]
or
(B[A],C[not(A)])
for your example:

declare namespace tf=‘http://namespaces.softwareag.com/tamino/TaminoFunction
let $persons:=(for $Person in input()/Person
where (tf:containsText($Person/Name ,‘for’))
return $Person/Name)
return
(
{count($persons)} [count($persons) gt 1000],
($persons) [count($persons) le 1000]
)