This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:variable
- To: xsl-list at mulberrytech dot com
- Subject: Re: xsl:variable
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Wed, 10 May 2000 15:32:11 +0100 (BST)
- References: <20000510140121.6378.qmail@web4105.mail.yahoo.com>
- Reply-To: xsl-list at mulberrytech dot com
<xsl:template match="/">
<xsl:variable name="global"/>
<!-- Other tag -->
</xsl:template>
Is it correct?
Is the variable empty?
It is syntactically correct, but strange.
If you define it like that then
a) the variable is only usable in that one template rather than in all
of them as it would have been if you had put the xsl:variable outside
the template and
b) It has value a result tree template that just has a root node.
Thus acts in almost all contexts like the empty string.
An XSL variable never changes its value once it is bound so
this is not very useful definition for $global.
<xsl:template match="pb">
<xsl:variable name="global">
<xsl:value-of select="$global"/>
This is again correct put again strange.
You have defined another variable (also called global)
that is local to this template, and again defined it to be empty.
Another question why the <div> and </div> are not in
the variable global
Because you defined the variable to be empty.
You quoted my suggestion of defining it to be
> <xsl:variable name="global">
> <xsl:value-of select="/the/first/node/you/want"/>
> <xsl:value-of select="/the/second/node/you/want"/>
> <xsl:value-of select="/the/third/node/you/want"/>
> </xsl:variable>
but you didn't put this declaration at the top level of your stylesheet,
and you didn't change those xpaths to select whatever it is you want to
select.
David
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list