This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Variables in XSL


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]