title: How to process all data from multiple XML files after merging using XSL
body: <p>I am using XSL to read in three XML documents which are identical except their attributes have  different values (potentially I will be reading many XML files).  I want to count the number of times the "outcome" attribute has a value "Passed" or "Failed" for the  element whose "testName" attribute = "TestOne".  I am achieving this using the following:</p>
  
  <p><strong>File1.xml</strong></p>
  
  <pre><code>&lt;container&gt;
      &lt;build&gt;
          &lt;Tests&gt;
              &lt;Results&gt;
                  &lt;Result testName="TestOne" outcome="Passed" &gt;&lt;/Result&gt;
                  &lt;Result testName="TestTwo"  outcome="Passed" &gt;&lt;/Result&gt;
              &lt;/Results&gt;
          &lt;/Tests&gt;    
      &lt;/build&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p><strong>File2.xml</strong></p>
  
  <pre><code>&lt;container&gt;
      &lt;build&gt;
          &lt;Tests&gt;
              &lt;Results&gt;
                  &lt;Result testName="TestOne" outcome="Passed" &gt;&lt;/Result&gt;
                  &lt;Result testName="TestTwo"  outcome="Failed" &gt;&lt;/Result&gt;
              &lt;/Results&gt;
          &lt;/Tests&gt;    
      &lt;/build&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p><strong>File3.xml</strong></p>
  
  <pre><code>&lt;container&gt;
      &lt;build&gt;
          &lt;Tests&gt;
              &lt;Results&gt;
                  &lt;Result testName="TestOne" outcome="Failed" &gt;&lt;/Result&gt;
                  &lt;Result testName="TestTwo"  outcome="Failed" &gt;&lt;/Result&gt;
              &lt;/Results&gt;
          &lt;/Tests&gt;    
      &lt;/build&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p><strong>Index.xml</strong></p>
  
  <pre><code>&lt;?xml-stylesheet type="text/xsl" href="merge3.xsl"?&gt;
  &lt;list&gt;
      &lt;entry name="File1.xml" /&gt;
      &lt;entry name="File2.xml" /&gt;
      &lt;entry name="File3.xml" /&gt;
  &lt;/list&gt;
  </code></pre>
  
  <p><strong>Merge2.xsl</strong></p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="html"/&gt;
  
  &lt;xsl:template match="/"&gt;
      &lt;xsl:for-each select="/list/entry"&gt;
          &lt;xsl:apply-templates select="document(@name)/container/build/*[local-name()='Tests']" /&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="*[local-name()='Results']"&gt;
      &lt;xsl:variable name="name" select="'TestOne'" /&gt;
      &lt;xsl:variable name="totalPassed" select="*[local-name()='Result'][@testName = 'TestOne'][@outcome = 'Passed']" /&gt;
      &lt;xsl:variable name="totalFailed" select="*[local-name()='Result'][@testName = 'TestOne'][@outcome = 'Failed']" /&gt;
  
      &lt;h2&gt;Totals&lt;/h2&gt;
      &lt;table border="1" cellSpacing="0" cellPadding="5" &gt;
          &lt;tr bgcolor="#9acd32"&gt;
              &lt;th&gt;Test Name&lt;/th&gt;
              &lt;th&gt;Total Passed&lt;/th&gt;
              &lt;th&gt;Total Failed&lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;xsl:value-of select="$name"/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;xsl:value-of select="count($totalPassed)"/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;xsl:value-of select="count($totalFailed)"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The result produces 3 Totals tables.  My intention is to display one Totals table displaying how many times TestOne has passed and failed in all the XML documents.
  It seems each XML document is being read/selected and then processed one at a time.  I'd like to read in and select all the XML files before processing them.  </p>