[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl:variable question

Subject: RE: xsl:variable question
From: "Long Zhao" <LZhao@xxxxxxxxxxxxxxxx>
Date: Wed, 19 Dec 2001 16:52:06 -0600
xsl mode variable
the second one dose work, since the variable is declared in top level
template.
and the son and grandson templates called should be able to access it.

I found the problem, for the first one, i should have something like
<xsl:if test="$mode=1"> instead of <xsl:if test="$mode='1'"> 

cheers

Long

-----Original Message-----
From: Joshua.Kuswadi@xxxxxxxxxxxxxxxxxxxx
[mailto:Joshua.Kuswadi@xxxxxxxxxxxxxxxxxxxx]
Sent: Wednesday, December 19, 2001 4:47 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  xsl:variable question


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


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.