Lawrence said:
Is there any way of using variables in XSLT? I have been using
<xsl
aram name="showDetails"/> and want to be able to set it to say 1
or 0 dependent on certain XSL:if statements throughout...is this
possible?
Parameters are useful to pass values to templates e.g. if you declare
<xsl:template name="template-name">
<xsl
aram name="param-name"/>
<!-- body of template comes here -->
</xsl:template>
then elsewhere in your stylesheet you can call that template and pass in
a value for the parameter e.g.
<xsl:call-template name="template-name">
<xsl:with-param name="param-name">
<xsl:choose>
<xsl:when test="some condition">some value</xsl:when>
<xsl
therwise>some other value</xsl
therwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
Variables can be declared and bound to a value using e.g.
<xsl:variable name="variable-name" select="expression"/>
You can bind a value once, it is not possible to change that later.
So if you want to use some condition checks you need to do that when
using xsl:variable e.g.
<xsl:variable name="variable-name">
<xsl:choose>
<xsl:when test="some condition">some value</xsl:when>
<xsl
therwise>some other value</xsl
therwise>
</xsl:choose>
</xsl:variable>