Wrox Programmer Forums
| 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 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
  #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

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

[u]XSL:</u>
<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
  #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
Default

Code:
sum(Charge/@Amount | SAPCreditItem/@CreditAmount[.!=''])
/- Sam Judson : Wrox Technical Editor -/
  #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
Default

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
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference


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





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