Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] help to get data before '%' of 'value' attribute in element 'coverage'

From: "Mikael Petterson (KI/EAB)" <mikael.petterson@------------>
To:
Date: 9/1/2005 7:08:00 AM
Hi,

I am trying to create a new report containing data from a file called
coverage.xml ( see part of it below).

I am using the following xsl to get it:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
    <xsl:output method="html"/>
    <!-- Main -->
    <xsl:template match="/">
    <html>
    <body>
     <h1 align="center">Code Coverage for Qrank Report</h1>
       <table align="center" cellpadding="8" cellspacing="0" border="0"
width="98%">
    <xsl:apply-templates select="." mode="qrank.view" />
      </table>
    </body></html>
    </xsl:template>

    <xsl:template match="/" mode="qrank.view">
    <xsl:variable name="fpx.packages.count"
select="count(report/data/all/package[contains(@name,'se.company.product.subs
ys.boam.fpx')])"/>
    <xsl:variable name="main.packages.count"
select="count(report/data/all/package[contains(@name,'se.company.product.subs
ys.boam.main')])"/>
    <xsl:variable name="common.packages.count"
select="count(report/data/all/package[contains(@name,'se.company.product.subs
ys.boam.common')])"/>
    <tr>
    <xsl:choose>
          <!-- select package fpx -->
          <xsl:when
test="report/data/all/package[contains(@name,'se.company.product.subsys.boam.
fpx')]">
            <xsl:variable name="measure"/>
            <!-- get 'coverage' attribute 'value' before % -->
            <xsl:with-param name="measure"
select="substring-before(report/data/all/package/coverage[@type='block,
%']/@value,'%')"/>
            Value of fpx: <xsl:value-of select="$measure"/>
          </xsl:when>
          <!-- select package main -->
          <xsl:when
test='contains(@name,"se.company.product.subsys.boam.main")'>
          </xsl:when>
           <!-- select package common -->
          <xsl:when
test='contains(@name,"se.company.product.subsys.boam.common")'>
          </xsl:when>
          <xsl:otherwise>

          </xsl:otherwise>
    </xsl:choose>
    </tr>
   </xsl:template>
</xsl:stylesheet>

When I transform using this template I get:

Result
=====

<html>
<body>
<h1 align="center">Code Coverage for Qrank Report</h1>
<table align="center" cellpadding="8" cellspacing="0" border="0" width="98%">
<tr>
            Value of fpx: </tr>
</table>
</body>
</html>

I suspect the following line

substring-before((/report/data/all/package/coverage[@type='block,
%']/@value),'%')


I have tried the following line in  XPath Explorer:

report/data/all/package/coverage[@type='block, %']/@value

It gives the following result:

*	value='0% (0/174)'
*	value='15% (28/188)'
*	value='25% (109/435)'
......

Then I tried the following in the  XPath Explorer:

substring-before((/report/data/all/package/coverage[@type='block,
%']/@value),'%')

The result is:

0



How can I get the values 0 , 15 and 25 and 'add' the together?

All hints are VERY much appreciated!

//mikael


coverage.xml
=========
<?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">
        <coverage type="class, %" value="3%   (2/58)"/>
        <coverage type="method, %" value="0%   (0/58)"/>
        <coverage type="block, %" value="0%   (0/174)"/>
        <coverage type="line, %" value="0%   (0/58)"/>
      </package>
      <package name="se.company.product.subsys.boam.mao.iface.enum.hidden">
        <coverage type="class, %" value="0%   (0/2)"/>
        <coverage type="method, %" value="0%   (0/2)"/>
        <coverage type="block, %" value="0%   (0/6)"/>
        <coverage type="line, %" value="0%   (0/2)"/>
      </package>
      <package name="se.company.product.subsys.boam.mao.iface.excep.hidden">

.........


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent