Re: Variables in XSL

Subject: Re: Variables in XSL
From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx>
Date: Tue, 20 Jun 2000 10:01:04 -0400
dave.challis@xxxxxxxxxxx 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:when test="some_complex_set_of_conditions">
      <xsl:value-of select="'1'" />
      <xsl:value-of select="'0'" />

Hope this helps.

Warren Hedley

 XSL-List info and archive:

Current Thread