title: XQuery that updates if something is true and otherwise returns error
body: <p>I'm trying to create a xquery expressions that inserts some new nodes only if a condition is true and returns an error if the condition is false. A simplyfied version of my state is:</p>
  
  <pre><code>let $a := [...]
  
  return 
    if($a/@something != "true") then (
       insert node (
              element {'Foobar'} { }
          ) into $a/somenode
    ) else ( 
  
    )
  </code></pre>
  
  <p>My problem: whenever if put something like <code>&lt;Error/&gt;</code> into the else i get an error "[XUST0001] No updating expression allowed in this context". </p>
  
  <p>/e: Okay...if I understand this correctly i can't have updateing expressions AND a return value....so I have to find another way.</p>