title: Update multiple XML files using XQuery and Zorba
body: <p>Is there a simple way using the Zorba XQuery Processor to update multiple XML files and save the output of the modification back in the same file?</p>
  
  <p>So far I have figured out how to process multiple files using the File module and the file:list extension to find all the XML files in a directory. I then loop through each document and run an XQuery Update statement (replace value of node {} with {}). The problem is that this doesn't actually modify the file.</p>
  
  <p>I was using Saxon before, but the license costs are too expensive for this particular project. In Saxon EE, if I ran a "replace value of node" on an open document, the document would be updated on the disk when the query was finished. I suspect Zorba doesn't work this way, instead only modifying the value in memory during the query. If I was editing one file I would just output the modified XML in Zorba and pipe that back to the input file, but in this case I want to update many files. Is that possible in one query?</p>
  
  <p>Here is what the code looks like:</p>
  
  <pre><code>import module namespace file = "http://expath.org/ns/file";
  
  for $file in file:list("XML", true(), "*.xml")
  let $doc := doc(concat("XML/", $file))
  return
  {
      for $key in $doc//key
      return
          replace value of node $key/texture
          with replace($key/material/text(), ".mat", ".png")
  }
  </code></pre>