[xquery-talk] Can I have multiple if's in a for loop (Not if-else if, but if, if, if..)

John Snelson john.snelson at marklogic.com
Mon Apr 18 11:33:48 PDT 2011

On 18/04/11 09:54, sudheshna iyer wrote:
> Can I have multiple if's in a for loop?  I noticed that it works, if I use -->
> if (ONE) then ...else if (TWO) then ... else if (THREE) then .. else()
> But I want all the three if "ReturnParameterCode" is repeated with all the three
> values

Sure, use parentheses and the comma operator, like this:

for $a in (1 to 10)
return (
   if(ONE) then ... else (),
   if(TWO) then ... else (),
   if(THREE) then .. else ()


John Snelson, Senior Engineer                  http://twitter.com/jpcs
MarkLogic Corporation                         http://www.marklogic.com

More information about the talk mailing list