|
Subject: Re: [xsl] xsl:when conditions From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 16 Aug 2001 17:35:53 +0100 |
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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] xsl:when conditions, Stuart Wilson | Thread | RE: [xsl] xsl:when conditions, Crowers, Steve |
| Re: [xsl] URL variables, Jeni Tennison | Date | Re: [xsl] XPath for getting the nea, Jeni Tennison |
| Month |