|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
Here's an introduction to recursive programming with XSL: http://www-106.ibm.com/developerwor...ecur/?n-x-10242
|
|
#5
|
|||
|
|||
|
Thanks for directing me.
I will go through it . |
|
#6
|
|||
|
|||
|
Hi
There is another example of recursion with XSLT http://forums.devshed.com/t81870/s.html Regards mono |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Re-assigning a variable's value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|