title: XQuery to change attribute value and return previous one
body: <p>I'm trying to update an attribute value of a node and return its previous value all in one query and I can't find a way to do it. I'm using <a href="http://basex.org/" rel="nofollow">BaseX</a> as my XML/XQuery database.</p>
  
  <p>For now I've tried doing this:</p>
  
  <pre><code>/Root/Elem/properties/property[@id='17']/@format,
  replace value of node /Root/Elem/properties/property[@id='17']/@format with 'URL'
  </code></pre>
  
  <p>and also this:</p>
  
  <pre><code>for $prop in /Root/Elem/properties/property[@id='17']
      let $format := $prop/@format
      return (replace value of node $prop/@format with 'URL', $format)
  </code></pre>
  
  <p>And multiple other tests but they all lead to the following error:</p>
  
  <pre><code>List expression: no updating expression allowed.
  </code></pre>
  
  <p>Is it a limitation of BaseX or is it not possible in XQuery?</p>