Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 9th, 2008, 12:28 AM
Authorized User
Join Date: Jul 2008
Location: , , .
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default NaN

[u]XSLT:</u> Version 1.0
[u]Platform: </u>Windows XP

<Charge Id="77" Amount="139.97" CurrCode="EUR" Type="5" PT="P"/>
<SAPCreditItem CreditDate="20080520" CreditAmount=""/>

<xsl:variable name="total" select="Charge[@Id='77' and @Type='5' and @PT='P']/@Amount + SAPCreditItem/@CreditAmount"/>

[u]Result:</u> <xsl:value-of select="$total"/>

I tried with, <xsl:variable name="total" select="Charge[@Id='77' and @Type='5' and @PT='P']/@Amount[number()=number()] + SAPCreditItem/@CreditAmount[number()=number()]"/>...But again the output is Nan.

How to avoid NaN. When the value is empty( CreditAmount="" ) as shown above.

[u]Expected result:</u> 139.97
[u]Actual result:</u> NaN
Reply With Quote
  #2 (permalink)  
Old September 9th, 2008, 02:47 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

sum(Charge/@Amount | SAPCreditItem/@CreditAmount[.!=''])
/- Sam Judson : Wrox Technical Editor -/
Reply With Quote
  #3 (permalink)  
Old September 9th, 2008, 04:10 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

Please don't ask the same question on several forums at the same time. It's reasonable to ask one one forum if another one fails to come up with the answer, but to use several at once is bad etiquette - it's like ordering free drinks from more than one barman and then leaving one of them untouched.

Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a NaN in VBA? rahzan Access VBA 11 March 6th, 2016 08:40 AM
NaN spinout ASP.NET 2.0 Basics 4 August 5th, 2007 06:07 AM
Formatting NaN in a matrix gidsy BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 May 8th, 2007 10:50 AM
Actionscript NaN brainchild Flash (all versions) 1 March 21st, 2007 07:29 AM
format-number NaN rbdave XSLT 1 October 23rd, 2003 06:48 AM

All times are GMT -4. The time now is 06:48 AM.

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