[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

help to get data before '%' of 'value' attribute in

Subject: help to get data before '%' of 'value' attribute in element 'coverage'
From: "Mikael Petterson (KI/EAB)" <mikael.petterson@xxxxxxxxxxxx>
Date: Thu, 1 Sep 2005 09:07:07 +0200
coverage.xml package
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">

.........

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.