Count matching packages

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

  1. How can I count all java packages that contains fpx in their name using
    xslt?

    cheers,

    //mikael

    I have the following data:

    <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>
    ......................
     
    Petterson Mikael, Aug 31, 2005
    #1
    1. Advertising

  2. Petterson Mikael

    Joris Gillis Guest

    Tempore 12:47:01, die Wednesday 31 August 2005 AD, hinc in foro {comp.text.xml} scripsit Petterson Mikael <>:

    > How can I count all java packages that contains fpx in their name using
    > xslt?


    count(/report/data/all/package[contains(@name,'fpx')])

    --
    Joris Gillis (http://users.telenet.be/root-jg/me.html)
    «Numquam mores quos extuli refero» - Seneca , Ad Lucilium I, 7
     
    Joris Gillis, Aug 31, 2005
    #2
    1. Advertising

  3. Joris Gillis wrote:
    > Tempore 12:47:01, die Wednesday 31 August 2005 AD, hinc in foro
    > {comp.text.xml} scripsit Petterson Mikael
    > <>:
    >
    >> How can I count all java packages that contains fpx in their name using
    >> xslt?

    >
    >
    > count(/report/data/all/package[contains(@name,'fpx')])
    >


    Thanks that worked fine!

    Two more questions:

    How can I get the value ( percentage e.g. 65%) of attribute value for
    element coverage?

    When shall I use [ ] ?

    cheers,

    //mikael

    I have the following data:

    <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>
    ......................
     
    Petterson Mikael, Aug 31, 2005
    #3
  4. Petterson Mikael wrote:
    > Joris Gillis wrote:
    >
    >> Tempore 12:47:01, die Wednesday 31 August 2005 AD, hinc in foro
    >> {comp.text.xml} scripsit Petterson Mikael
    >> <>:
    >>
    >>> How can I count all java packages that contains fpx in their name using
    >>> xslt?

    >>
    >>
    >>
    >> count(/report/data/all/package[contains(@name,'fpx')])
    >>

    >
    > Thanks that worked fine!
    >
    > Two more questions:
    >
    > How can I get the value ( percentage e.g. 65%) of attribute value for
    > element coverage?
    >
    > When shall I use [ ] ?
    >
    > cheers,
    >
    > //mikael
    >
    > I have the following data:
    >
    > <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>
    > .....................



    I have tried the following Xpath expression:

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

    Then I get "all" values for attribute value.
    I need to get one/two/three digits e g. 5% or 24% or 100%. Is it
    possible to do this?

    cheers,

    //mikael
     
    Petterson Mikael, Aug 31, 2005
    #4
  5. Petterson Mikael wrote:
    > Petterson Mikael wrote:
    >
    >> Joris Gillis wrote:
    >>
    >>> Tempore 12:47:01, die Wednesday 31 August 2005 AD, hinc in foro
    >>> {comp.text.xml} scripsit Petterson Mikael
    >>> <>:
    >>>
    >>>> How can I count all java packages that contains fpx in their name using
    >>>> xslt?
    >>>
    >>>
    >>>
    >>>
    >>> count(/report/data/all/package[contains(@name,'fpx')])
    >>>

    >>
    >> Thanks that worked fine!
    >>
    >> Two more questions:
    >>
    >> How can I get the value ( percentage e.g. 65%) of attribute value for
    >> element coverage?
    >>
    >> When shall I use [ ] ?
    >>
    >> cheers,
    >>
    >> //mikael
    >>
    >> I have the following data:
    >>
    >> <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>
    >> .....................

    >
    >
    >
    > I have tried the following Xpath expression:
    >
    > /report/data/all/package/coverage[@type='block, %']/@value
    >
    > Then I get "all" values for attribute value.
    > I need to get one/two/three digits e g. 5% or 24% or 100%. Is it
    > possible to do this?
    >
    > cheers,
    >
    > //mikael


    Hi,

    I thought of using:

    substring-before(@value,'%') but don't know how to add it to the xpath
    expression.

    All help is appreciated!

    cheers,

    //mikael
     
    Petterson Mikael, Aug 31, 2005
    #5
  6. Petterson Mikael

    Joris Gillis Guest

    > substring-before(@value,'%') but don't know how to add it to the xpath
    > expression.


    substring-before(/report/data/all/package/coverage[@type='block, %']/@value,'%') ?
     
    Joris Gillis, Aug 31, 2005
    #6
  7. Joris Gillis wrote:
    >> substring-before(@value,'%') but don't know how to add it to the xpath
    >> expression.

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


    Hmmm....

    I can't get this to work. My Xpath explorer is returning 0.
    Any idea why?

    //mikael
     
    Petterson Mikael, Sep 1, 2005
    #7
    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. Paul  Smith
    Replies:
    0
    Views:
    734
    Paul Smith
    Nov 18, 2003
  2. Marcel Akkerman
    Replies:
    5
    Views:
    873
    Marcel Akkerman
    Feb 22, 2004
  3. David Lyon
    Replies:
    19
    Views:
    583
    David Lyon
    Apr 24, 2009
  4. efelnavarro09
    Replies:
    2
    Views:
    940
    efelnavarro09
    Jan 26, 2011
  5. Ian
    Replies:
    3
    Views:
    171
Loading...

Share This Page