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

Subject: [xsl] Binding or re-binding tunnel parameters in the middle of a template
From: Greg Beauchesne <greg.beauchesne@xxxxxxxxx>
Date: Tue, 22 Dec 2009 12:22:10 -0500
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

Current Thread