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

RE: Calculating Averages

Subject: RE: Calculating Averages
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 26 Jun 2002 23:23:43 +0100
calculating averages
Getting the topics with the same id is a standard grouping problem: for
example

<xsl:variable name="t" select="//topic[not(id=preceding::topic/id)]"/>

Then it's just:

<xsl:for-each select="$t">
  <xsl:variable name="nz" select="//topic[id=current()/id][score!=0]"/>
  <xsl:value-of select="sum($nz/score) div count($nz/score)"/>
</

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Sendrey, John
> Sent: 26 June 2002 20:58
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  Calculating Averages
> 
> 
> Just wondering how i could get an average topic score (per 
> topic) where score of 0 are excluded.
> 
> ------
> OUTPUT:
> ------
> <topics>
> 	<topic>
> 		<id>1</id>
> 		<mean>5</mean>
> 	</topic>
> 	<topic>
> 		<id>2</id>
> 		<mean>3.5</mean>
> 	</topic>
> 	<topic>
> 		<id>3</id>
> 		<mean>5</mean>
> 	</topic>
> 	<topic>
> 		<id>4</id>
> 		<mean>5</mean>
> 	</topic>
> </topics>
> -----
> INPUT:
> -----
> .
> .
> .
> <eval>
> 	<id>1</id>
> 	<topics>
> 		<topic>
> 			<id>1</id>
> 			<score>5</score>
> 		</topic>
> 		<topic>
> 			<id>2</id>
> 			<score>4</score>
> 		</topic>
> 		<topic>	
> 			<id>4</id>
> 			<score>5</score>
> 		</topic>
> 	</topics>
> </eval>
> <eval>
> 	<id>5</id>
> 	<topics>
> 		<topic>	
> 			<id>2</id>
> 			<score>3</score>	
> 		</topic>
> 		<topic>	
> 			<id>3</id>
> 			<score>5</score>
> 		</topic>
> 		<topic>
> 			<id>4</id>
> 			<score>0</score>
> 		</topic>
> 	</topics>
> </eval>
> .
> .
> .
> 
>  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.