Is it possible to re-declare a variable?
This is an open discussion with 7 replies, filed under General.
Search
Apologies - the example above was meant to be....
variable = 0
if something = something variable = 1 end if
if variable = 1 do something else do something else end if
You could do it like this:
<xsl:variable name="my-variable"> <xsl:choose> <xsl:when test="/data/foo = 'bar'">1</xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable>
Thanks for your help - would this be the same if there was a while statement around the choose one?
There is no while statement in XSLT. :-)
The only loop structure in XSLT is for-each, and it is not possible to declare a variable within such a loop.
In XSLT a 'variable' within a template can have a different value each time the template is called. It is not possible to change the value of a so-called variable once it has been set.
If you declare variable = 0 to create the variable within a scope, this is not working. Parameters are the global variables and cannot be changed by xsl. You can loop through entries, compare a value with a parameter and conditionally generate the template needed.
Play with URL or datasource parameters
Create an account or sign in to comment.
Hey guys, a bit stumped whilst using XSLT. This is basically what I am trying to do...
variable = 0
variable = 1
Later in the document.....
Do something Do something else
Is this possible? If so - can you please advise the correct syntax to use.
Thanks very much in advance