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 November 9th, 2011, 03:33 AM
Registered User
 
Join Date: Nov 2011
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default Adding two string decimal values in XSLT

Hi,

I need to add two decimal values in XSLT1.0.

<Col align="left" colwidth="4.40"/>
<Col align="left" colwidth="5.40"/>

When i try using something like below and then adding these two values, it is giving me "NaN".

<xsl:param name="calculateWidth">
<xsl:value-of select="number(@colwidth)"/>
</xsl:param>

<xsl:value-of select="$calculateWidth= $calculateWidth+ number(@colwidth)"/>

Is there any alternative to add these numbers?


Thanks.
 
Old November 9th, 2011, 04:08 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

try the below
Code:
<xsl:value-of select="sum(Col/@ colwidth)"/>
__________________
Rummy
 
Old November 9th, 2011, 06:18 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There's nothing obviously wrong with your code (though it seems cumbersome). The most likely reason it fails is that the context node isn't the Col element. Note that mrame's suggestion assumes that the context node is the parent of the Col element.
__________________
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
adding up values in xslt northwind XSLT 21 February 17th, 2017 09:07 AM
Decimal to string harold4964 BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 2 May 2nd, 2011 01:18 AM
Adding XSLT Values with Matching Headings RabbitPack XSLT 4 August 6th, 2009 05:02 AM
Allowing Decimal values bright_mulenga Access 1 February 12th, 2007 12:38 PM
Decimal to String ?!? TPP XSLT 1 January 18th, 2007 12:08 PM





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