4

I wish to do the following:

let $foo :=
    if (5 = 5)
    then
        return <bye/>
    else
        return <hi/>

But unfortunately the above doesn't work.

How do I do if statments for let statements.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231
  • It's the "return" that's the problem. Deleting the "saxon" tag as there is nothing here that's specific to Saxon. – Michael Kay Dec 02 '15 at 09:06

1 Answers1

7

You want to do something like:

let $foo :=
    if (5 = 5) then
        <bye/>
    else
        <hi/>

then you can return the result with

return
  $foo

I suggest you download basex editor from http://files.basex.org/releases/latest/ in order to test any xquery. It's fast, and can highlight errors for you.

Also take a look at http://xqdoc.org/xquery-style.html for examples on writing clean xquery code.

George Sofianos
  • 440
  • 1
  • 7
  • 17