<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output encoding="utf-8" indent="yes"/>
	<xsl:param name="suitename"/>

  <xsl:template match="testsuite">

    <testsuites name="{normalize-space(@name)}" >
   
    <xsl:for-each select="testsuite">
      <testsuite name="{normalize-space(@name)}" time="{normalize-space(@time)}" package="unittest" tests="{normalize-space(@tests)}" failures="{normalize-space(@failures)}" errors="{normalize-space(@errors)}">

        <xsl:variable name="b">
	  <xsl:value-of select="@name"/>
        </xsl:variable>
	
        <xsl:for-each select="testcase">
          <xsl:variable name="msg">
	     <xsl:value-of select="failure/@message"/>
	  </xsl:variable>

          <xsl:variable name="res">
             <xsl:choose>
	        <xsl:when test="$msg=''">passed</xsl:when>
	        <xsl:otherwise>failed</xsl:otherwise>
	     </xsl:choose>
	  </xsl:variable>

	  <testcase name="{normalize-space(@name)}" time="{normalize-space(@time)}" result="{$res}" errors="">
	    <xsl:if test="not($msg='')">
	      <failure type="" message="{$msg}" />
   	    </xsl:if>
	  </testcase>
      
        </xsl:for-each>
      </testsuite> 

      <xsl:apply-templates/>		

    </xsl:for-each>			
    </testsuites>
  </xsl:template>
</xsl:stylesheet>

