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 March 24th, 2009, 11:23 AM
Registered User
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question how to assign one variable value to another xsl variable in xsl

below code is used for print the radio button for route_opt is same (for both R1,R1 then radion button is one )

temp and route_opt is xsl variable
i am assiging the route_opt value to temp variable but it is not changing outside the when condition. but it is change in when condition how it is possible ???.if any way how to assign ????
consider route_opt contains
route_opt contains R1,R1,R2,R2 and changes continously resepctively.
1st and second time (in detail2) loop time temp and route_opt is same but 3rd time it is not same then goes to otherwise condition in that change value and newly assign route_opt value to temp variable and it is assign but outside it is not change for 4th time.


<xsl:variable name="temp"><xsl:value-of select="//Detail2/route_opt"/></xsl:variable>
<xsl:for-each select ="//Detail2">
<xsl:variable name="route_opt"><xsl:value-of select="route_opt"/></xsl:variable>

<xsl:choose>
<xsl:when test="normalize-space($line_no)=normalize-space($line_no__tkt_chk)">
<TD id="td2_{$route_opt}" class="editDisplayClass" width="3%">
<INPUT id="selRadioId_{$route_opt}" TYPE="radio" name="Detail2.{normalize-space($line_no__grptkt)}.selected" ISCHANGED="true" value="Y" checked="false" selected="{$selected}" amount="{$amount}" grpId="{$line_no__grptkt}" net_amt="{$net_amt}" lineNo="{$line_no}" line_no__grptkt="{$line_no__grptkt}" onclick="setValues( this );" /></TD>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="normalize-space($route_opt) = normalize-space($temp)">
</xsl:when>
<xsl:otherwise>
<TD id="td2_{$route_opt}" class="editDisplayClass" width="3%">
<INPUT id="selRadioId_{$route_opt}" TYPE="radio" name="Detail2.{normalize-space($line_no__grptkt)}.selected" ISCHANGED="true" value="Y" checked="false" selected="{$selected}" amount="{$amount}" grpId="{$line_no__grptkt}" net_amt="{$net_amt}" lineNo="{$line_no}" line_no__grptkt="{$line_no__grptkt}" onclick="setValues( this );" /></TD>
<xsl:variable name ="temp" select="normalize-space($route_opt)"/>

</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>

Last edited by Anil_Base; March 24th, 2009 at 11:33 AM.. Reason: ADD MORE TEXT
 
Old March 24th, 2009, 12:39 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If you post a small but representative XML input sample and the corresponding HTML you want to create with your stylesheet then we are hopefully able to show you how to achieve that with XSLT.
Please also mention whether you use XSLT 2.0 or 1.0.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old March 24th, 2009, 12:42 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

In general variables in XASLT are more lik constants, once assigned they cannot be changed. Can you show a small example of what you need without the extraneous material as I am finding it hard to understand the problem? Where for example are you trying to assign $route_opt to $temp?

As a side issue this:
Code:
<xsl:variable name="temp"><xsl:value-of select="//Detail2/route_opt"/></xsl:variable>
is normally better written as:
Code:
<xsl:variable name="temp" select="//Detail2/route_opt"/>
__________________
Joe
http://joe.fawcett.name/
 
Old March 24th, 2009, 01:17 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You haven't explained yourself very clearly (start by finding the shift key on your keyboard, a few capital letters can help a lot, whereas multiple question marks help very little). I think you've almost certainly not understood that XSLT is a declarative, function language and not a procedural one, and that it needs a different approach if your previous experience is with procedural languages. It's worth standing back and explaining your requirements, rather than trying to fix your code.
__________________
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
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
xsl:variable holding name of an xsl:param perissos XSLT 0 December 5th, 2006 07:09 AM
The difference between xsl:variable and xsl:param NEO1976 XML 2 July 24th, 2006 06:05 AM
pass java variable to xsl variable kathy1016cats XSLT 1 June 14th, 2006 06:23 PM
how to assign fo:page-number to a xsl:variable or jyotsnag XSLT 0 March 14th, 2006 01:49 AM





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