Is it possible to create a variable inside a variable in xslt??
Is the above thing possible???
Is it possible to create a variable inside a variable in xslt??
Is the above thing possible???
Is this what you mean?
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" version="2.0">
<xsl:variable name="a">
<xsl:variable name="b" select="10"/>
<xsl:value-of select="$b"/>
</xsl:variable>
<xsl:template match="/">
<xsl:value-of select="$a"/>
</xsl:template>
</xsl:stylesheet>
The answer is yes, but the inner variable is in scope only within the definition of the outer variable. So if the definition of the outer variable calls for some complex expression that you'd like to store in a temporary (possibly for debugging purposes), then this is a way to do it.
The answer is: yes. This stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="vOuter">
<xsl:variable name="vInner">
<xsl:value-of select="'Content'"/>
</xsl:variable>
<xsl:value-of select="concat('Some ',$vInner)"/>
</xsl:variable>
<xsl:value-of select="$vOuter"/>
</xsl:template>
</xsl:stylesheet>
Output:
Some Content