[xsl] Converting non-numeric characters to numbers

Subject: [xsl] Converting non-numeric characters to numbers
From: "Scott Downie" <sdownie@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 7 Mar 2001 09:38:25 -0600
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


Current Thread