title: Using XSLT, how to get an attribute from multiple xml files outputed into one single file?
body: <p>I have the following situation: out of multiple almost similar in structure xml files, I need to extract an attribute and the file from which it comes from.</p>
  
  <p>I believe I am close to a solution, but cannot make it work. I am new to xml and xslt and would need some guidance. Thank you.</p>
  
  <p>My multiple xml files are all in the same location and they have the following structure:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;erpConnector&gt;
    &lt;sections&gt;
      &lt;section name="Section1"&gt;
        &lt;!-- other irrelevant content here --&gt;
      &lt;/section&gt;
      &lt;section name="Section2"&gt;
        &lt;!-- other irrelevant content here --&gt;
      &lt;/section&gt;
      &lt;section name="Section3"&gt;
        &lt;!-- other irrelevant content here --&gt;
      &lt;/section&gt;
    &lt;/sections&gt;
  &lt;/erpConnector&gt;  </code></pre>
  </div>
  </div>
  </p>
  
  <p>I created a separate xml file called "report.xml" which acts like an aggregator for all my other xml files. It looks like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="reports3.xsl" version="1.0"?&gt;
  &lt;report&gt;
   &lt;title&gt;Section names&lt;/title&gt;
   &lt;configfile name="C:\Users\.myFirstXMLfile.xml"/&gt;
   &lt;configfile name="C:\Users\mySecondXMLfile.xml"/&gt;
  &lt;/report&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Lastly, I have the xsl file:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
   &lt;xsl:output method="html" indent="no"/&gt;
   &lt;xsl:strip-space elements="*"/&gt;
   
   &lt;xsl:template match="/"&gt;
    &lt;html&gt;
     &lt;head&gt;
      &lt;title&gt;&lt;xsl:value-of select="/report/title"/&gt;&lt;/title&gt;
     &lt;/head&gt;
     &lt;body&gt;
      &lt;xsl:for-each select="/report/configfile"&gt;
       &lt;xsl:apply-templates select="document(@name)/erpConnector"/&gt;
      &lt;/xsl:for-each&gt;
     &lt;/body&gt;
    &lt;/html&gt;
   &lt;/xsl:template&gt;
  
   &lt;xsl:template match="/"&gt;
    &lt;h1&gt;
     &lt;xsl:value-of select="erpConnector/sections/section/@name"/&gt;
     &lt;xsl:text&gt; &lt;/xsl:text&gt;
    &lt;/h1&gt;
   &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My output is just "&lt;h1&gt; &lt;\h1&gt;" .</p>
  
  <p>Please let me know what could be the cause and how to address it.</p>
  
  <p>The output could look like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;h2&gt;Basic HTML Table&lt;/h2&gt;
  
  &lt;table style="width:100%"&gt;
    &lt;tr&gt;
      &lt;th&gt;Section name&lt;/th&gt;
      &lt;th&gt;Filename&lt;/th&gt; 
  
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Section1&lt;/td&gt;
      &lt;td&gt;myfirstxml&lt;/td&gt;
  
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Section2&lt;/td&gt;
      &lt;td&gt;mysecondxml&lt;/td&gt;
  
    &lt;/tr&gt;
  &lt;/table&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  
  But if any other format is easier to obtain, that would be fine as well.</p>
  
  <p>Thank you!</p>