This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Initializing global variables


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]