sum codecoverage values for different groups

Discussion in 'XML' started by Petterson Mikael, Aug 31, 2005.

  1. 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">
    <xsl:eek:utput 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>
    <xsl:eek:therwise>

    </xsl:eek:therwise>
    </xsl:choose>
    </tr>
    </xsl:for-each>
    </body></html>
    </xsl:template>

    <xsl:template name="calc">
    <xsl:param 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">
    Petterson Mikael, Aug 31, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Petra Hübner
    Replies:
    0
    Views:
    444
    Petra Hübner
    Feb 16, 2004
  2. anonymous
    Replies:
    1
    Views:
    4,584
    Francisco Padron
    May 8, 2005
  3. Rolf Kemper

    sum values by lookup

    Rolf Kemper, Dec 23, 2004, in forum: XML
    Replies:
    2
    Views:
    646
    Luke Dalessandro
    Dec 23, 2004
  4. Replies:
    3
    Views:
    360
    Peter Hansen
    Jun 10, 2005
  5. The alMIGHTY N
    Replies:
    1
    Views:
    622
    Joris Gillis
    Feb 9, 2007
Loading...

Share This Page