[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Converting non-numeric characters to numbers
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|