This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Variables in XSL
- To: xsl-list at mulberrytech dot com
- Subject: Re: Variables in XSL
- From: Warren Hedley <w dot hedley at auckland dot ac dot nz>
- Date: Tue, 20 Jun 2000 10:01:04 -0400
- Organization: Department of Engineering Science, The University of Auckland
- References: <EC01C7655988D311818100500455B50623C875@stargate_2.finatec.com>
- Reply-To: xsl-list at mulberrytech dot com
dave.challis@FINATEC.com wrote:
>
> Is it possible to set the value of a variable at different points in an xsl
> file?
Unfortunately, no. "variable" is a bit of a misnomer in that respect.
> For example, is it possible to declare a variable to be true somewhere, and
> then set it to false when it comes across a certain element type?
What you can do is have arbitrarily complex expressions in your variable
initialisation, where some tricky checks are performed. Of course the
contents of the variable are a result-tree-fragment, so you can't pretend
they're a nodeset later on, but if you just want to store a boolean or a
string, this isn't a problem.
<xsl:variable name="really_complex">
<xsl:choose>
<xsl:when test="some_complex_set_of_conditions">
<xsl:value-of select="'1'" />
</xsl:when>
...
<xsl:otherwise>
<xsl:value-of select="'0'" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Hope this helps.
--
Warren Hedley
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list