This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:when conditions
- To: Stuart Wilson <coracle at totalise dot co dot uk>
- Subject: Re: [xsl] xsl:when conditions
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Thu, 16 Aug 2001 17:35:53 +0100
- CC: XSL-List at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <3B8EBBA1@mail.totalise.co.uk>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Stuart,
> In the XSL below I'm trying to pass a optional parameter called
> "alignment" into a template. When the parameter is not passed into
> the template I want to assign a default value (left) to the variable
> "alignment"
You can use the select attribute or the content of the xsl:with-param
element to set the default value of the parameter. In your case, you
should use:
<xsl:template name="writeline">
<xsl:param name="text" />
<xsl:param name="alignment" select="'left'" />
</xsl:template>
> <xsl:template name="writeline">
> <xsl:param name="text"/>
> <xsl:param name="alignment"/>
> <xsl:variable name="alignment">
> <xsl:choose>
> <xsl:when test="$alignment"> <===== This syntax causes error
> <xsl:value-of select="$alignment"/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="string('left')"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:variable>
[snip]
> </xsl:template>
Your problem in this template is that you're declaring a variable with
the same name as an existing parameter. You can't have a variable and
parameter with the same name, nor can you change the value of a
variable or parameter once it's been set.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list