|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:when conditions
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








