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

Re: using default params?

Subject: Re: using default params?
From: "Nikolai Grigoriev" <grig@xxxxxxx>
Date: Tue, 28 Mar 2000 23:28:05 +0400
xsl with param default
> But I don't want to always give the full set of attributes, but
> instead have my xsl respect default values.
>
> ...
> 
> So I tried to do some stupid and nonworking tricks with xsl:call-template:
> 
> <xsl:template match="foo">
>  <xsl:call-template name="foo_pr">
>    <xsl:with-param name="col1" select="@col1"/>
>    <xsl:with-param name="col2" select="@col2"/>
>    <xsl:with-param name="col3" select="@col3"/>
>  </xsl:call-template>
> </xsl:template>

You got very close. Try to modify your with-param calls
like this:

    <xsl:with-param name="col1">
       <xsl:choose>
         <xsl:when test="@col1">
           <xsl:value-of select="@col1"/>
         </xsl:when>
         <xsl:otherwise>#FFFFFF<xsl:otherwise>
       </xsl:choose>
    </xsl:with-param>

For readability's sake, you may find it useful to store
the color in a variable:

<xsl:template match="foo">
  <xsl:variable name="expanded-col1">
     <xsl:choose>
       <xsl:when test="@col1">
         <xsl:value-of select="@col1"/>
       </xsl:when>
       <xsl:otherwise>#FFFFFF<xsl:otherwise>
     </xsl:choose>
  </xsl:variable>
  <!-- [same for $expanded-col2 and $expanded-col3 - skipped] -->

  <xsl:call-template name="foo_pr">
    <xsl:with-param name="col1" select="$expanded-col1"/>
    <xsl:with-param name="col2" select="$expanded-col2"/>
    <xsl:with-param name="col3" select="$expanded-col3"/>
  </xsl:call-template>
 </xsl:template>

Regards,

Nikolai
     



 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.