title: Using xsl to parse xml output, use of variables?
body: <p>I'm trying to parse an xml file output from googletest to display the results in a pretty way in an html page. I have had a fair crack at it and have a working solution. Only one thing left to do.
  Currently each class has a header and each function+test is displayed underneath, I'm looking for a way to extract the function name from the xml attribute to have it as its own sub-heading. Example below</p>
  
  <hr>
  
  <h2>Current Output</h2>
  
  <p><strong>Class Name</strong><br>
  functionName_testName<br>
  functionName_test2Name<br>
  function2Name_testName<br>
  <br/></p>
  
  <h2>Desired Output</h2>
  
  <p><strong>Class Name</strong><br>
  <em>functionName</em><br>
  testName<br>
  test2Name<br>
  <em>function2Name</em><br>
  testName  </p>
  
  <p><strong>XML To be Parsed</strong></p>
  
  <pre><code>&lt;testsuite name="testPacketProcessor" tests="27" failures="0" disabled="0" errors="0" time="36.875"&gt;
      &lt;testcase name="testInitialise_IpNotSet" status="run" time="0" classname="testPacketProcessor" /&gt;
      &lt;testcase name="testInitialise_GoodIp" status="run" time="2.046" classname="testPacketProcessor" /&gt;
      &lt;testcase name="testInitialise_BadIp" status="run" time="0.032" classname="testPacketProcessor" /&gt;
  &lt;/testsuite&gt;
  </code></pre>
  
  <p>XSL Currently Implemented</p>
  
  <pre><code>&lt;xsl:for-each select="testsuites/testsuite"&gt;
      &lt;div class="testHeading"&gt;
          &lt;span&gt;&lt;xsl:value-of select="substring-after(@name,'test')"/&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;xsl:for-each select="testcase"&gt;
      &lt;div class="testReport"&gt;
          &lt;xsl:if test="not(starts-with(@name,'DISABLED'))"&gt;&lt;xsl:value-of select="substring-after(@name,'test')"/&gt;&lt;/xsl:if&gt;
          &lt;xsl:if test="starts-with(@name,'DISABLED')"&gt;&lt;xsl:value-of select="substring-after(@name,'DISABLED_test')"/&gt;&lt;/xsl:if&gt;
          &lt;xsl:text&gt; - &lt;/xsl:text&gt;
          &lt;xsl:if test="starts-with(@status,'run')"&gt;
              &lt;xsl:if test="failure"&gt;&lt;xsl:text&gt;Fail&lt;/xsl:text&gt;&lt;/xsl:if&gt;
              &lt;xsl:if test= "not(failure)"&gt;&lt;xsl:text&gt;Pass&lt;/xsl:text&gt;&lt;/xsl:if&gt;
          &lt;/xsl:if&gt;
          &lt;xsl:if test="starts-with(@status,'not')"&gt;&lt;xsl:text&gt;Disabled&lt;/xsl:text&gt;&lt;/xsl:if&gt;
      &lt;/div&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>Using the above xml as an example I would like a subheading of "Initialise" under the packet processor heading with each test doucumented under the subheading</p>
  
  <p>Any advice on the best way to go about this would be much appreciated. I've looked at xsl variables but cannot fathom how to deal with not being able to change the value. Have also read a little on xsl templates and recursion but I'm not sure how that would work for this situation.</p>
  
  <p>Thanks in advance</p>
  
  <p>Dougie</p>