Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 7th, 2006, 09:43 AM
Authorized User
 
Join Date: Oct 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reg Sum() function

Hi all

sum(@Amount) returns NaN, when there is not value against the attribute Amount?

How can I return the total value?

thx
suri

 
Old December 7th, 2006, 02:33 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

sum(@amount) only looks at one attribute node, presumably your real expression is something like sum(xxx/@amount). This will only look at amount attributes that actually exist. Is your problem that some attributes take the form amount=""? If you want to exclude these from the sum, use sum(xx/@amount[.!='']). More generally if you want to exclude any attribute whose value is non-numeric, use sum(xx/@amount[string(number(.)) != 'NaN'])

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old December 7th, 2006, 03:17 PM
Authorized User
 
Join Date: Oct 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That is what I was looking for...
Thanks a lot..!!

suri







Similar Threads
Thread Thread Starter Forum Replies Last Post
sum function pcase XSLT 2 January 2nd, 2008 05:51 PM
SUM Function in ASP kylej2006 Classic ASP Basics 10 June 7th, 2007 05:46 PM
sum() function felixm_jr Reporting Services 1 April 22nd, 2007 01:59 AM
SUM Function jmss66 Classic ASP Basics 17 July 29th, 2003 08:00 AM
Need Help with the Sum Function athanatos XSLT 1 July 22nd, 2003 10:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.