title: XSLT Transform for XML Generated by metric.exe
body: <p>I'm trying to transform the following XML generated by metric.exe for assemblies in my solution. and i am not an expert in XSLT and struggling to arrive at the format indicated at the bottom of the question. please help.</p>
  
  <p><strong>The XML</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;CodeMetricsReport Version="12.0"&gt;
    &lt;Targets&gt;
      &lt;Target Name="E:\some-imaginary-path\some-imaginary-dll"&gt;
        &lt;Modules&gt;
          &lt;Module Name="some-imaginary-dll" AssemblyVersion="1.0.0.0" FileVersion="1.0.0.0"&gt;
            &lt;Metrics&gt;
              &lt;Metric Name="MaintainabilityIndex" Value="84" /&gt;
              &lt;Metric Name="CyclomaticComplexity" Value="95" /&gt;
              &lt;Metric Name="ClassCoupling" Value="109" /&gt;
              &lt;Metric Name="DepthOfInheritance" Value="4" /&gt;
              &lt;Metric Name="LinesOfCode" Value="214" /&gt;
            &lt;/Metrics&gt;
            &lt;Namespaces&gt;
              &lt;Namespace Name="LMS.SomeNamespace"&gt;
                &lt;Metrics&gt;
                  &lt;Metric Name="MaintainabilityIndex" Value="89" /&gt;
                  &lt;Metric Name="CyclomaticComplexity" Value="19" /&gt;
                  &lt;Metric Name="ClassCoupling" Value="18" /&gt;
                  &lt;Metric Name="DepthOfInheritance" Value="1" /&gt;
                  &lt;Metric Name="LinesOfCode" Value="29" /&gt;
                &lt;/Metrics&gt;
                &lt;Types&gt;
                  &lt;Type Name="SomeType1"&gt;
                    &lt;Metrics&gt;
                      &lt;Metric Name="MaintainabilityIndex" Value="100" /&gt;
                      &lt;Metric Name="CyclomaticComplexity" Value="1" /&gt;
                      &lt;Metric Name="ClassCoupling" Value="1" /&gt;
                      &lt;Metric Name="DepthOfInheritance" Value="0" /&gt;
                      &lt;Metric Name="LinesOfCode" Value="0" /&gt;
                    &lt;/Metrics&gt;
                    &lt;Members&gt;
                      &lt;Member Name="SomeMemberFor1"&gt;
                        &lt;Metrics&gt;
                          &lt;Metric Name="MaintainabilityIndex" Value="100" /&gt;
                          &lt;Metric Name="CyclomaticComplexity" Value="1" /&gt;
                          &lt;Metric Name="ClassCoupling" Value="1" /&gt;
                          &lt;Metric Name="LinesOfCode" Value="0" /&gt;
                        &lt;/Metrics&gt;
                      &lt;/Member&gt;
                    &lt;/Members&gt;
                  &lt;/Type&gt;
                  &lt;Type Name="SomeType2"&gt;
                    &lt;Metrics&gt;
                      &lt;Metric Name="MaintainabilityIndex" Value="76" /&gt;
                      &lt;Metric Name="CyclomaticComplexity" Value="3" /&gt;
                      &lt;Metric Name="ClassCoupling" Value="6" /&gt;
                      &lt;Metric Name="DepthOfInheritance" Value="1" /&gt;
                      &lt;Metric Name="LinesOfCode" Value="7" /&gt;
                    &lt;/Metrics&gt;
                    &lt;Members&gt;
                      &lt;Member Name="SomeMemberFor2" File="e:\some-file.cs" Line="27"&gt;
                        &lt;Metrics&gt;
                          &lt;Metric Name="MaintainabilityIndex" Value="67" /&gt;
                          &lt;Metric Name="CyclomaticComplexity" Value="2" /&gt;
                          &lt;Metric Name="ClassCoupling" Value="5" /&gt;
                          &lt;Metric Name="LinesOfCode" Value="6" /&gt;
                        &lt;/Metrics&gt;
                      &lt;/Member&gt;
                &lt;/Namespace&gt;
            &lt;/Namespaces&gt;
          &lt;/Module&gt;
               &lt;/Namespace&gt;
            &lt;/Namespaces&gt;
          &lt;/Module&gt;
        &lt;/Modules&gt;
      &lt;/Target&gt;
    &lt;/Targets&gt;
  &lt;/CodeMetricsReport&gt;
  </code></pre>
  
  <p><strong>The XSLT</strong></p>
  
  <p>so far this produces nothing when transformed using a powershell script (certain variations have worked partially so the powershell script is not at fault here)</p>
  
  <pre><code>&lt;xsl:stylesheet 
    version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
    exclude-result-prefixes="msxsl"
  &gt;
    &lt;xsl:output method="html" indent="yes"/&gt;
     &lt;xsl:template match="/"&gt;
    &lt;html&gt;
    &lt;body&gt;
    &lt;h2&gt;x&lt;/h2&gt;
    &lt;table border="1"&gt;
      &lt;tr bgcolor="#9acd32"&gt;
        &lt;th&gt;Name Space Name&lt;/th&gt;
        &lt;th&gt;Type Name&lt;/th&gt;
        &lt;th&gt;Member Name&lt;/th&gt;
        &lt;th&gt;MaintainabilityIndex&lt;/th&gt;
        &lt;th&gt;CyclomaticComplexity&lt;/th&gt;
        &lt;th&gt;ClassCoupling&lt;/th&gt;
        &lt;th&gt;DepthOfInheritance&lt;/th&gt;
        &lt;th&gt;LinesOfCode&lt;/th&gt;
  
      &lt;/tr&gt;
      &lt;xsl:for-each select="CodeMetricsReport/Targets/Target/Modules/Namespaces/Namespace/Metrics"&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;xsl:value-of select="./Metric[@Name = '????']/@Value" /&gt;&lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select="./Metric[@Name = '????']/@Value" /&gt;&lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select="./Metric[@Name = '????']/@Value" /&gt;&lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select="./Metric[@Name = 'MaintainabilityIndex']/@Value" /&gt;&lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select="./Metric[@Name = 'CyclomaticComplexity']/@Value"/&gt;&lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select="./Metric[@Name = 'ClassCoupling']/@Value"/&gt;&lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select="./Metric[@Name = 'DepthOfInheritance']/@Value"/&gt;&lt;/td&gt;
        &lt;td&gt;&lt;xsl:value-of select="./Metric[@Name = 'LinesOfCode']/@Value"/&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/xsl:for-each&gt;
    &lt;/table&gt;
    &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>the HTML that i am expecting achive</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table border="1"&gt;
    &lt;tr bgcolor="#9acd32"&gt;
      &lt;th&gt;Name Space Name&lt;/th&gt;
      &lt;th&gt;Type Name&lt;/th&gt;
      &lt;th&gt;Member Name&lt;/th&gt;
      &lt;th&gt;MaintainabilityIndex&lt;/th&gt;
      &lt;th&gt;CyclomaticComplexity&lt;/th&gt;
      &lt;th&gt;ClassCoupling&lt;/th&gt;
      &lt;th&gt;DepthOfInheritance&lt;/th&gt;
      &lt;th&gt;LinesOfCode&lt;/th&gt;
  
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Name of namespace&lt;/td&gt;
      &lt;td&gt;Type name&lt;/td&gt;
      &lt;td&gt;Member name&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;5&lt;/td&gt;
    &lt;/tr&gt;
  
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thanks in advance for any help rendered.</p>