Subject: Re: [xsl] Calculate average value recursively From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Sun, 22 Jan 2006 14:51:22 +0100 |
I'm trying to calculate the average for a set of rainfall values in the following node-set:
<month number="1"> <day number="1"> <rainfall>1.5</rainfall> </day> <day number="2"> <rainfall>0.5</rainfall> </day> <day number="3"> <rainfall>TR</rainfall> </day> ... </month>
Usually, I'd use "sum(month/day/rainfall) div count(month/day)" to get the average rainfall, however, as null values are represented as "TR", that expression returns a NaN error.
Just avoid selecting "TR" values, for example: sum(month/day/rainfall[.!='TR']) div count(month/day[rainfall!='TR']) or sum(month/day/rainfall[.!='TR']) div count(month/day) depending on what your definition of "average" is.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Calculate average value recur, Weiran Zhang | Thread | [xsl] xsl:attribute vs "expected co, Eric Scheid |
[xsl] Calculate average value recur, Weiran Zhang | Date | [xsl] xsl:attribute vs "expected co, Eric Scheid |
Month |