XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 4th, 2003, 03:31 AM
faheemhameed faheemhameed is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 5 faheemhameed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 35 sec
Reputation Power: 0
Re-assigning a variable's value

Hi there,

I am very new to XSL. I wanted to do the following:

Assign a variable named "Total_Amount" in the global scope.

Then I loop through each child nodes using

<xsl:for-each select="RESULTSET/ROW">

and add the node value of "Amount" to the global "Total_Amount" variable and finally display it as Grand Total at the end.

<xsl:variable name="Total_Amount"><xsl:value-of select="$Total_Amount + $Amount"/></xsl:variable>

But the global variable is not being modified. It seems that it creates a local variable with the same name of the global variable.

Also it seems that a variable within the for loop is not global even within each iteration of the loop.

I have no idea how to work this around.
Please shed some lights on my issue.

Thanks a lot.
Hameed

Reply With Quote
  #2  
Old September 4th, 2003, 12:06 PM
kahaji kahaji is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 7 kahaji User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
What version of XSLT are you using ?
To the best of my knowledge, re-assigning variables is not an option until XSLT 1.1.

variables once declared using <xsl:variable> cannot be re-assigned.
You can however achieve what you want by using xsl:call-template by passing the values recursively.

Reply With Quote
  #3  
Old September 5th, 2003, 02:38 AM
faheemhameed faheemhameed is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 5 faheemhameed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 35 sec
Reputation Power: 0
Hi kahaji,

Thanks for your reply. Can you please give an example of how to use xsl:call-template and pass the value recursively to achieve what I wanted.

Thanks a lot.

Hameed

Reply With Quote
  #4  
Old September 5th, 2003, 04:45 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Here's an introduction to recursive programming with XSL: http://www-106.ibm.com/developerwor...ecur/?n-x-10242

Reply With Quote
  #5  
Old September 8th, 2003, 12:58 AM
faheemhameed faheemhameed is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 5 faheemhameed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 35 sec
Reputation Power: 0
Thanks for directing me.

I will go through it .

Reply With Quote
  #6  
Old September 9th, 2003, 01:09 PM
mono mono is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Bulgaria
Posts: 30 mono User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via ICQ to mono
Hi

There is another example of recursion with XSLT
http://forums.devshed.com/t81870/s.html


Regards
mono

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Re-assigning a variable's value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway