Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use "if statements" in "let" statements in xquery

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.

like image 207
Yahya Uddin Avatar asked Oct 18 '25 05:10

Yahya Uddin


1 Answers

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.

like image 129
George Sofianos Avatar answered Oct 22 '25 04:10

George Sofianos