title: xQuery simple if not empty conditional
body: <p>I'm trying to learn xQuery coming from a php background, I have this expression working as expected</p>
  
  <pre><code>&lt;![CDATA[
  declare variable $doc as node() external;
  declare variable $id external;
  
  let $cont := data($doc//div[@class="cont"])
  let $title := data($doc//p[@class="vtitle"])
  let $text := data($doc//div[@class="venue-cont-left"])
  return 
      &lt;venue id="{$id}"&gt;
          &lt;title&gt;{$title}&lt;/title&gt;
          &lt;text&gt;{$text}&lt;/text&gt;
      &lt;/venue&gt;     
  ]]&gt;  
  </code></pre>
  
  <p>However now I simply want to make a check weather $title is empty or not</p>
  
  <pre><code>&lt;![CDATA[
      declare variable $doc as node() external;
      declare variable $id external;
  
  if(empty(data($doc//p[@class="vtitle"]))) then
  (
          let $id :=$id
      return  
       &lt;venue id="{$id}" /&gt;
  ) else (
  let $cont := data($doc//div[@class="cont"])
  let $title := data($doc//p[@class="vtitle"])
  let $text := data($doc//div[@class="venue-cont-left"])
  return 
      &lt;venue id="{$id}"&gt;
          &lt;title&gt;{$title}&lt;/title&gt;
          &lt;text&gt;{$text}&lt;/text&gt;
      &lt;/venue&gt;
  )    
  ]]&gt;
  </code></pre>
  
  <p>This does not work because i get this resulting output</p>
  
  <pre><code>&lt;venue id="4"&gt;
     &lt;title/&gt;
     &lt;text&gt;
  PHONE:
  ADDRESS:....
  </code></pre>
  
  <p>As you see venue 4 has no title so it should have been returned as <code>&lt;venue id="4" /&gt;</code></p>
  
  <p>Thanks for any help!</p>