Subject: RE: Converting non-numeric characters to numbers
From: Don Bruey <dbruey@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 7 Mar 2001 11:07:07 -0500
|
try
<xsl:variable name="TotalSum" select="sum(AAA/BBB[string(number(.)) !=
'NaN'])" />
This sums all AAA/BBB that are numeric (whose "number()" value is not 'NaN')
Don
-----Original Message-----
From: Scott Downie [mailto:sdownie@xxxxxxxxxxxxxxxxxxxx]
Sent: Wednesday, March 07, 2001 10:38 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Converting non-numeric characters to numbers
I have been thrown into XSL and XML head first and have bumped into a
stumbling block.
I am trying to use the sum() function, but part of the data I am
receiving in the XML is non-numeric.
For example my XML would be as follows:
<AAA>
<BBB>123</BBB>
<BBB>456</BBB>
<BBB>-</BBB>
<BBB>789</BBB>
</AAA>
The XSL I am trying to use is
<xsl:variable name="TotalSum" select="sum(AAA/BBB)">
When doing this I get back NaN.
I have also tried
<xsl:variable name="TotalSum" select="sum(AAA/BBB[not '-'])">
but return 0
I will eventually need to perform other calculations such as average,
min, max, and median so I need a way to exclude the '-' from my
calculations or convert it to '0' via XSL.
Any help would be appreciated.
Thanks in Advance.
Lindy
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|