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

Re: Find a set of nodes and depending on element value

Subject: Re: Find a set of nodes and depending on element values
From: "Erik Stunkat" <Erik.Stunkat@xxxxxxx>
Date: Tue, 5 Mar 2002 11:43:49 +0100
loadsize
Works, thanks!!

erik


                                                                                                                          
                    Jakub.Valenta@xxxxxxxx                                                                                
                    Sent by:                          To:     xsl-list@xxxxxxxxxxxxxxxxxxxxxx                             
                    owner-xsl-list@xxxxxxxxxxxx       cc:                                                                 
                    rytech.com                        Subject:     Re:  Find a set of nodes and depending on element 
                                                       values                                                             
                                                                                                                          
                    03/04/2002 05:28 PM                                                                                   
                    Please respond to xsl-list                                                                            
                                                                                                                          
                                                                                                                          





Hi,
hope this helps


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl
="http://www.w3.org/1999/XSL/Transform">
     <xsl:key name = "example"  match ="/loadtest/rounds/action" use
= "./loadsize" />

     <xsl:template match="/">
      <!-- this selects the <action nodes according to loadsize parameter
<xsl:copy-of select="key('example','1')"/>
        -->
      <result>
       <xsl:value-of select="sum(key('example','1')/time) div count(key
('example','1'))" />
      </result>
     </xsl:template>
</xsl:stylesheet>


gives you:

<?xml version="1.0" encoding="utf-8"?>
<result>17.666666666666668</result>

br,

Jakub





"Erik Stunkat" <Erik.Stunkat@xxxxxxx>@lists.mulberrytech.com on 03/04/2002
05:53:17 PM

Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx

Sent by:  owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To:   XSL-List@xxxxxxxxxxxxxxxxxxxxxx
cc:

Subject:   Find a set of nodes and depending on element values

Hi!

I have a simple xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
<loadtest><settings task="Export"  host="http://animal:8080" format
="BMECat" size="1000"  ></settings><rounds>
<action><user>user0-0</user><command>completed</command><loadsize>1</loadsize><time>18</time><output></output></action>


<action><user>user0-1</user><command>completed</command><loadsize>1</loadsize><time>17</time><output></output></action>


<action><user>user0-2</user><command>completed</command><loadsize>1</loadsize><time>18</time><output></output></action>


<action><user>user0-3</user><command>completed</command><loadsize>5</loadsize><time>18</time><output></output></action>


<action><user>user0-4</user><command>completed</command><loadsize>5</loadsize><time>18</time><output></output></action>


</rounds></loadtest>


Now I want to find all <action> elements with the element
<loadsize>1</loadsize> and then process the average time (<time>xxx</time>)
for each set of action elements with the same time.

 <xsl:value-of select="sum(/time[loadsize='1']) div count(time[loadsize
='1'])"/> does not work...

My problem is to find the correct nodeset -  for-each gives me the strings
, not the elements.

thanks in advance!

erik stunkat


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.