This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: using default params?


"Nikolai Grigoriev" <grig@iitp.ru> writes:

> > But I don't want to always give the full set of attributes, but
> > instead have my xsl respect default values.
>
> 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>

Ok, I didn't mention that I tried this, too but it appeared to me that
this is just to much typing. In my "real" work I don't pass 3 but up
to 8 parameters.... 

> 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] -->

This last "skipped" is the main reason I want to have something
different :-)
 
>   <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,

thank you very much,

        jtl


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]