How to conditional output xml tag using xquery

I want to use xquery to transform an xml document to another one. Some of the tags in the output xml are conditional based on the value of the input xml document. How to write this in xquery? I used following xquery statement:
if (fn:not(fn:empty($s))) then fn:concat("", $var1, “</BOOK”) else “”
But the output from the xquery replaced ‘<’ with &lt and ‘>’ with &gt. Is this the correct way of implementing this? How to avoid such replacement?


very simple:

if (fn:not(fn:empty($s))) then <BOOK>{$var1}</BOOK> else ()

or better

if ($s) then <BOOK>{$var1}</BOOK> else ()

The following also works:


Thank you, it worked.