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

RE: Converting non-numeric characters to numbers

Subject: RE: Converting non-numeric characters to numbers
From: Don Bruey <dbruey@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 7 Mar 2001 11:07:07 -0500
non numeric characters
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


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.