|
|
 |
| 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

March 24th, 2009, 12:23 PM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 12:33 PM.
Reason: ADD MORE TEXT
|

March 24th, 2009, 01:39 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Location: Germany
Posts: 655
Thanks: 0
Thanked 98 Times in 97 Posts
|
|
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
My blog
|

March 24th, 2009, 01:42 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,922
Thanks: 0
Thanked 13 Times in 12 Posts
|
|
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
|

March 24th, 2009, 02:17 PM
|
 |
Wrox Author
Points: 12,738, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,924
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |