Converting QtTest output to a Bitten Report

Unit tests created with the QtTest framework can optionally output the test results in XML format, by passing the -xml flag. I use the Bitten plugin for Trac to run full builds with each subversion commit; the following stylesheet formats the test reports correctly for display on the Bitten build page and graphs.

<?xml version="1.0"?>
<!-- Converts QtTest XML output to a bitten report output.-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="TestCase">
  <report category="test">
  <xsl:text>
</xsl:text>
  <xsl:apply-templates select="TestFunction"/>
  </report>
</xsl:template>
<xsl:template match="TestFunction">
  <xsl:apply-templates select="Incident"/>
</xsl:template>
<xsl:template match="Incident">
  <xsl:variable name="resulttext">
   <xsl:choose>
    <xsl:when test="@type='pass'">
      <xsl:text>success</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>failure</xsl:text>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:variable>
  <xsl:variable name="testname">
    <xsl:value-of select="../@name"/>
  </xsl:variable>
  <xsl:variable name="testcase">
    <xsl:value-of select="../../@name"/>
  </xsl:variable>
  <!-- Because of the way bitten displays test results, it is useful
   to exchange test fixture and name strings here -->
  <test name="{$testcase}" status="{$resulttext}" fixture="{$testname}"/>
  <xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>