how to use if else in xquery assignment

Viewed 72817

I am trying to use a if condition to assign a value to a variable in an xquery. I am not sure how to do this.

This is what I tried:

declare namespace libx='http://libx.org/xml/libx2';
declare namespace atom='http://www.w3.org/2005/Atom';
declare variable $entry_type as xs:string external;
let $libx_node :=
    if ($entry_type = 'package' or 'libapp') then
      {element {fn:concat("libx:", $entry_type)} {()} }
    else if ($entry_type = 'module') then
      '<libx:module>
        <libx:body>{$module_body}</libx:body>
      </libx:module>'

This code throws an [XPST0003] Incomplete 'if' expression error. Can someone help me fix this?

Also, can someone suggest some good tutorials to learn xqueries.

Thanks, Sony

1 Answers
Related