This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:variable question
- From: "Thomas B. Passin" <tpassin at mitretek dot org>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 19 Dec 2001 17:23:06 -0500
- Subject: Re: [xsl] xsl:variable question
- References: <912374CEB1784F4284E58AE281F70C9F27235F@MAIL-02VS.atlarge.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Aside from the question about the scope of the variable, which Wendell and
Joshua raised, there is a fundamental issue. In the first example, you
assign a value "1" to the variable. In the second, you try to assign a
nodeset consisting of elements named "1", which of course cannot exist since
it would be illegal for an element name. To make the second formulation
equivalent, you should write
<xsl:variable name="mode" select='"1"'/>
(that's '.."1"..' where I am inserting two dots to space out the inner and
outer quotes for visibility). This assigns the string value "1" to the
variable, just as in the first example.
Cheers,
Tom P
[Long Zhao]
here are two xsl files :
<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?
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list