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 June 24th, 2006, 12:05 PM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default regarding adding numbers in xsl

Hello

I am new to xsl/xslt. I have following xml

<response>
   <txn_no>1234</txn_no>
   <amount_to_pay>100</amount_to_pay>
</response>
<response>
   <txn_no>8745</txn_no>
   <amount_to_pay>200</amount_to_pay>
</response>
<response>
   <txn_no>5426</txn_no>
   <amount_to_pay>150</amount_to_pay>
</response>

I need to add the amount_to_pay and show it as grand total. How is this possible in xsl? I tried to assign value to variable but it doesnot allow to change it.
 
Old June 24th, 2006, 12:12 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Use

<xsl:value-of select="sum(response/txn_no)"/>

when the context node is the parent of the <response> elements.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
adding up 2 numbers in xsl umair.aziz XSLT 3 July 14th, 2006 09:24 AM
Adding numbers Hudson40 Excel VBA 3 November 23rd, 2005 03:02 AM
adding numbers gmoney060 Access 1 August 15th, 2004 08:14 PM
Adding numbers kend XSLT 4 June 27th, 2003 12:33 AM
Adding numbers kend XSLT 1 June 26th, 2003 10:14 AM





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