[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xsl:when conditions

Subject: Re: xsl:when conditions
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 17:35:53 +0100
condition with parameter passed xsl
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.