Re: [xsl] Binding or re-binding tunnel parameters in the middle of a template

Subject: Re: [xsl] Binding or re-binding tunnel parameters in the middle of a template
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 22 Dec 2009 17:30:26 +0000
The short answer is no, but I also don't really see it as a problem...
 if you spent much time passing parameters down through templates in
xslt 1.0 you would love tunnelled parameters in 2.0!

2009/12/22 Greg Beauchesne <greg.beauchesne@xxxxxxxxx>:
> Hello,
>
> I'm writing a transform that makes extensive use of tunnel parameters.
> In some cases, I find myself making a series of calls to which the same
> tunnel parameter is passed but which is not yet tunneled until the call
> itself (often times this is a modified version of the tunnel parameter
> that was passed in, but that's not really relevant here; just some
> background info):
>
> -----
> <xsl:template name="template">
>   <xsl:variable name="value" select="..." />
>
>   <xsl:call-template name="tunnelTemplate">
>     <xsl:with-param name="tunnelParam" select="$value" tunnel="yes" />
>   </xsl:call-template>
>   <xsl:call-template name="anotherTunnelTemplate">
>     <xsl:with-param name="tunnelParam" select="$value" tunnel="yes" />
>   </xsl:call-template>
>   <xsl:call-template name="yetAnotherTunnelTemplate">
>     <xsl:with-param name="tunnelParam" select="$value" tunnel="yes" />
>   </xsl:call-template>
> </xsl:template>
> -----
>
> Is there any simpler way of reusing that tunnel parameter without having
> to type the xsl:with-param over and over again other than wrapping that
> whole section in another template and calling that? e.g.:
>
> -----
> <xsl:template name="template">
>   <xsl:variable name="value" select="..." />
>
>   <xsl:call-template name="subTemplate">
>     <xsl:with-param name="tunnelParam" select="$value" tunnel="yes" />
>   </xsl:call-template>
> </xsl:template>
>
> <xsl:template name="subTemplate">
>   <xsl:call-template name="tunnelTemplate" />
>   <xsl:call-template name="anotherTunnelTemplate" />
>   <xsl:call-template name="yetAnotherTunnelTemplate" />
> </xsl:template>
> -----
>
> Removing the additional with-params would improve readability, but it
> would also be helpful to be able keep all the calls in one template.
> That would also mean I would not have to pass in any additional
> variables that were defined in "template".
>
> -- Greg
>
>



--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread