Re: [xsl] Passing parameters using <xsl:apply-templates>

Subject: Re: [xsl] Passing parameters using <xsl:apply-templates>
From: Eliot Kimber <ekimber@xxxxxxxxxxxx>
Date: Sat, 16 Feb 2008 04:53:56 -0600
Mark wrote:

Everything I can find on this I understand to tell me that I need to
pass the parameter through each element level of the processed xml
data otherwise that parameter passes no further than the last element
level it is set at. I am attempting this by setting the parameter
*intrefNow* in every template which I believe is therefore required.

If you use tunneling parameters then you only need to pass them when first set and only need to accept them when needed, e.g.:


<xsl:template match="docinc">
  <xsl:apply-templates>
    <xsl:with-param name="docuri" select="@href" tunneling="yes"/>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="some-element-that-cares">
  <xsl:param name="docuri" tunneling="yes"/>
</xsl:template>

Tunneling parameters are automatically passed down through apply-templates.

Tunneling parameters are new in XSLT 2.

Cheers,

Eliot

--
Eliot Kimber
Senior Solutions Architect
"Bringing Strategy, Content, and Technology Together"
Main: 610.631.6770
www.reallysi.com
www.rsuitecms.com

Current Thread