|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi Friends,
I stuck into a problem, could any body suggest me how can we assign the value to a global variable in the template or it's not allowed in xsl.I am trying... <xsl:variable name="out" select="$l+1"/> here out is global variable which i declared above the template & "l" is a local variable. Thanks Gunjan |
|
#2
|
|||
|
|||
|
i hope this is what u r looking for
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html" indent="no" encoding="utf-8"/><xsl:variable name="in" select="1000"/> <xsl:template match="/"> <xsl:variable name="out" expr="$in + 1"/> <xsl:value-of select="$out"/> </xsl:template> </xsl:stylesheet> --------------------- with regards niha |
|
#3
|
|||
|
|||
|
What i want?
Thanks niha for the reply what exactly i am trying to do is like that
<?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xslutput method="html" indent="no" encoding="utf-8"/> <xsl:variable name="out" select="1000"/> <xsl:template match="/"> <xsl:variable name="in" select="6"/> <!-- Now i want to manipulate the value of "out" so i can use it for diffrent purpose in the template --> <xsl:variable name="out" expr="$in +1"/> </xsl:template> </xsl:stylesheet> Hope now you can understand Thanks Gunjan |
|
#4
|
|||
|
|||
|
sorry i could not understand
sorry i could not understand actually..
bcoz i copied ur code and executed it is working fine to me anyway sorry i could not be more helpful ------------------------ <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl utput method="html" indent="no" encoding="utf-8"/><!--<xsl:variable name="in" select="1000"/> <xsl:template match="/"> <xsl:variable name="out" expr="$in + 1"/> <xsl:value-of select="$out"/> </xsl:template>--> <xsl:variable name="out" select="1000"/> <xsl:template match="/"> <xsl:variable name="in" select="8"/> <!-- Now i want to manipulate the value of "out" so i can use it for diffrent purpose in the template --> <xsl:variable name="out" expr="$in +1"/> <xsl:value-of select="$out"/> <br/> <xsl:value-of select="$out+1"/> </xsl:template> </xsl:stylesheet> --------------------- regards niha |
|
#5
|
|||
|
|||
|
please Just tell me that?
Is it possible in XSL that we assign the value to a global variable & later in the template we modify it's value.
Thanks Gunjan |
|
#6
|
|||
|
|||
|
xslt variables can not be updated
hi
according to XSLT Programmers reference Michael Kays book " unlike variables in many programming languages, XSLT variables can not be updated. Once they are given a innitial value, they retain that value until they go out of scope" (pg no:: 336) in ur case global variable means its scope is in entire that program so you can not updated it - this is whats my opinion anyway...if anyone out there got another theory would like to hear hope this info helps with regards niha |
|
#7
|
|||
|
|||
|
Thanks
Thanx niha that's what i just want to confirm.
Regards Gunjan |
|
#8
|
|||
|
|||
|
Hello,
Small tip. Usually you can use template calls or even recursive calls instead changing variable value. So use template parameter instead variable. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > xsl:variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|