This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Converting non-numeric characters to numbers
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] Converting non-numeric characters to numbers
- From: Don Bruey <dbruey at CreativeSolutions dot com>
- Date: Wed, 7 Mar 2001 11:07:07 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
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@euronetworldwide.com]
Sent: Wednesday, March 07, 2001 10:38 AM
To: xsl-list@lists.mulberrytech.com
Subject: [xsl] 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