P
Petterson Mikael
Hi,
In my xml file I have code coverage data ( see below).
Right below I have the xslt that I use to create a new html report.
I the new report I will show codecoverage for the 'fpx', 'main' and
'common' java packages ( group of packages containing the name in the
whole java package name).
How can I extract the attribute 'value' value for element 'coverage'
where attribute 'type' is "block, %". Then I need to calculate the
value for all packages containing fpx in package name ( that is why I
use <xsl:chosse> and <xsl:when>). Is it possible?
All hints are very much welcome!
cheers,
//mikael
xslt
----
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="html"/>
<!-- Main -->
<xsl:template match="/">
<html><body>
<xsl:for-each select="report/data/all/package">
<xsl:sort select="@name" order="descending" data-type="text"/>
<tr>
<xsl:choose>
<xsl:when
test='contains(@name,"se.company.product.subsys.boam.fpx")'>
<xsl:call-template name="calc">
<xsl:with-param name="measure" select="../coverage[@value]"/>
</xsl:call-template>
</xsl:when>
<xsl:when
test='contains(@name,"se.company.product.subsys.boam.main")'>
<!-- No impl yet -->
</xsl:when>
<xsl:when
test='contains(@name,"se.company.product.subsys.boam.common")'>
<!-- No impl yet -->
</xsl:when>
<xsltherwise>
</xsltherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</body></html>
</xsl:template>
<xsl:template name="calc">
<xslaram name="measure"/>
<td> <xsl:value-of select="$measure"/></td>
</xsl:template>
</xsl:stylesheet>
code coverage data
------------------
<?xml version="1.0" encoding="UTF-8"?><!-- EMMA v2.0.4217 report,
generated Fri Aug 26 09:24:18 MEST 2005 -->
<report>
<stats>
<packages value="44"/>
<classes value="1371"/>
<methods value="8293"/>
<srcfiles value="1356"/>
<srclines value="59524"/>
</stats>
<data>
<all name="all classes">
<coverage type="class, %" value="65% (892/1371)"/>
<coverage type="method, %" value="58% (4789/8293)"/>
<coverage type="block, %" value="53% (146231/274917)"/>
<coverage type="line, %" value="52% (31092.2/59524)"/>
<package name="se.company.product.subsys.boam.fpx.testsignals">
<coverage type="class, %" value="0% (0/2)"/>
<coverage type="method, %" value="0% (0/9)"/>
<coverage type="block, %" value="0% (0/61)"/>
<coverage type="line, %" value="0% (0/27)"/>
</package>
<package
name="se.company.product.subsys.boam.mao.dmo.auxdevice.tb.mock">
<coverage type="class, %" value="0% (0/1)"/>
<coverage type="method, %" value="0% (0/10)"/>
<coverage type="block, %" value="0% (0/51)"/>
<coverage type="line, %" value="0% (0/16)"/>
</package>
<package name="se.company.product.subsys.boam.mao.iface.enum">
In my xml file I have code coverage data ( see below).
Right below I have the xslt that I use to create a new html report.
I the new report I will show codecoverage for the 'fpx', 'main' and
'common' java packages ( group of packages containing the name in the
whole java package name).
How can I extract the attribute 'value' value for element 'coverage'
where attribute 'type' is "block, %". Then I need to calculate the
value for all packages containing fpx in package name ( that is why I
use <xsl:chosse> and <xsl:when>). Is it possible?
All hints are very much welcome!
cheers,
//mikael
xslt
----
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="html"/>
<!-- Main -->
<xsl:template match="/">
<html><body>
<xsl:for-each select="report/data/all/package">
<xsl:sort select="@name" order="descending" data-type="text"/>
<tr>
<xsl:choose>
<xsl:when
test='contains(@name,"se.company.product.subsys.boam.fpx")'>
<xsl:call-template name="calc">
<xsl:with-param name="measure" select="../coverage[@value]"/>
</xsl:call-template>
</xsl:when>
<xsl:when
test='contains(@name,"se.company.product.subsys.boam.main")'>
<!-- No impl yet -->
</xsl:when>
<xsl:when
test='contains(@name,"se.company.product.subsys.boam.common")'>
<!-- No impl yet -->
</xsl:when>
<xsltherwise>
</xsltherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</body></html>
</xsl:template>
<xsl:template name="calc">
<xslaram name="measure"/>
<td> <xsl:value-of select="$measure"/></td>
</xsl:template>
</xsl:stylesheet>
code coverage data
------------------
<?xml version="1.0" encoding="UTF-8"?><!-- EMMA v2.0.4217 report,
generated Fri Aug 26 09:24:18 MEST 2005 -->
<report>
<stats>
<packages value="44"/>
<classes value="1371"/>
<methods value="8293"/>
<srcfiles value="1356"/>
<srclines value="59524"/>
</stats>
<data>
<all name="all classes">
<coverage type="class, %" value="65% (892/1371)"/>
<coverage type="method, %" value="58% (4789/8293)"/>
<coverage type="block, %" value="53% (146231/274917)"/>
<coverage type="line, %" value="52% (31092.2/59524)"/>
<package name="se.company.product.subsys.boam.fpx.testsignals">
<coverage type="class, %" value="0% (0/2)"/>
<coverage type="method, %" value="0% (0/9)"/>
<coverage type="block, %" value="0% (0/61)"/>
<coverage type="line, %" value="0% (0/27)"/>
</package>
<package
name="se.company.product.subsys.boam.mao.dmo.auxdevice.tb.mock">
<coverage type="class, %" value="0% (0/1)"/>
<coverage type="method, %" value="0% (0/10)"/>
<coverage type="block, %" value="0% (0/51)"/>
<coverage type="line, %" value="0% (0/16)"/>
</package>
<package name="se.company.product.subsys.boam.mao.iface.enum">