This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Initializing global variables
- From: trang_nguyen at agilent dot com
- To: XSL-List at lists dot mulberrytech dot com
- Date: Wed, 5 Jun 2002 10:49:47 +0200
- Subject: [xsl] Initializing global variables
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
I understand that the value of a variable cannot be modified once it has been assigned, but is it possible to allocate a global variable at the start of a stylesheet and then assign it a value at a later time, such as within a named template?
Example (doesn't work since notepadDesc is treated as a local variable in portFreqTemplate):
<!-- Global variable to hold notepad (description) info -->
<xsl:variable name="notepadDesc">
</xsl:variable>
<xsl:template name="portFreqTemplate">
<xsl:param name="portFreqParam" />
<xsl:choose>
<!-- port and freq info available -->
<xsl:when test="contains($portFreqParam, '.')">
<port><xsl:value-of select = "substring-before($portFreqParam, '.')" /></port>
<!-- save freq info in a variable -->
<xsl:variable name="notepadDesc" select="concat('Freq: ', substring-after($portFreqParam, '.'))" />
</xsl:when>
...
</xsl:choose>
</xsl:template>
Thanks,
Trang
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list