title: XSLT Input file with settings - change multiple output files
body: <p>I'm using xslt to edit multiple files. I have input file that is my settings file, it looks like this:</p>
  
  <pre><code>&lt;root&gt;
    &lt;file&gt;
      &lt;folderin&gt;/var/in/&lt;/folderin&gt;
      &lt;in&gt;10&lt;/in&gt;
      &lt;folderout&gt;/var/out&lt;/folderout&gt;
      &lt;out&gt;20&lt;/out&gt;
      &lt;name&gt;First file&lt;/name&gt;
    &lt;/file&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>Example file:</p>
  
  <pre><code>&lt;root&gt;
    &lt;element1 id1="10"&gt;
      ...
    &lt;/element1&gt;
    &lt;element2 id2="10" attribute="xyz"&gt;
      ...
    &lt;/element2&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>And my xslt file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"&gt;
      &lt;xsl:output method="xml" indent="yes" encoding="utf-8"/&gt;
          &lt;xsl:template name="CopyXml" match="/*"&gt;
          &lt;xsl:for-each select="file"&gt;
              &lt;xsl:variable name="inputfile" select="concat(folderin, in, '.xml')"/&gt;
              &lt;xsl:variable name="outputfile" select="concat(folderout, out, '.xml')"/&gt;
  
              &lt;xsl:result-document method="xml" href="{$outputfile}"&gt;
                      &lt;xsl:copy-of select="document($inputfile)/*"/&gt;
              &lt;/xsl:result-document&gt;
              &lt;/xsl:for-each&gt;
          &lt;/xsl:template&gt;
  
      &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>In /var/in/ there are few hundred files from which i want to only edit few (in this example /var/in/10.xml with exit file /var/out/20.xml). In the new files i want to change id1 and id2 attribute value to my "out" param </p>
  
  <p>I've managed to copy those specific files with adequate names with my xslt, however i'm having problem applying any template so i could change those files. I've tried using apply-templates however i cannot make it apply those templates to the $outputFile, it's either not doing anything or appending $outputFile with copy from settings file;/ Does anyone have any idea how to do it?</p>
  
  <hr>
  
  <p>EDIT:
  Output for this example file:</p>
  
  <pre><code>&lt;root&gt;
    &lt;element1 id1="20"&gt;
      ...
    &lt;/element1&gt;
    &lt;element2 id2="20" attribute="xyz"&gt;
      ...
    &lt;/element2&gt;
  &lt;/root&gt;
  </code></pre>