Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 24th, 2006, 12:05 PM
Registered User
 
Join Date: Jun 2006
Location: , , Pakistan.
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.
Reply With Quote
  #2 (permalink)  
Old June 24th, 2006, 12:12 PM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 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
Reply With Quote
Reply


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
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



All times are GMT -4. The time now is 01:04 PM.


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