RE: [xsl] xsl:variable question

Subject: RE: [xsl] xsl:variable question
From: Joshua.Kuswadi@xxxxxxxxxxxxxxxxxxxx
Date: Thu, 20 Dec 2001 08:46:31 +1100
Hi Long,
> 
> <xsl:template match="/">
> 	<xsl:variable name="mode">1</xsl:variable>
> 	......
> </xsl:template>
> 
> <xsl:template name="dosomething">
> 	<xsl:if test="$mode='1'">
> 		.....
> 	</xsl:if>
> 	.....
> </template>
> ------------------------------------
> <xsl:template match="/">
> 	<xsl:variable name="mode" select='1'/>
> 	......
> </xsl:template>
> 
> <xsl:template name="dosomething">
> 	<xsl:if test="$mode='1'">
> 		.....
> 	</xsl:if>
> 	.....
> </template>
> 
> why the first one does not work, but the second one works.
> 
> am i doing anything wrong in the first xsl?

My first impression is that neither should work, as the scope of the mode variable is only defined within the first template. I'm not sure why your second one does work.

I would have a stylesheet like:
<xsl:stylesheet>
<xsl:variable name="mode" select="'1'"/>
<xsl:template match="/">
	......
</xsl:template>

<xsl:template name="dosomething">
	<xsl:if test="$mode='1'">
		.....
	</xsl:if>
	.....
</xsl:template>
</xsl:stylesheet>

HTH,
Joshua

------------------------------------------------------------------------------
This message and any attachment is confidential and may be privileged or otherwise protected from disclosure.  If you have received it by mistake please let us know by reply and then delete it from your system; you should not copy the message or disclose its contents to anyone.





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread