Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Variables and Parameters (14/14) >

Tunneling of parameters

If xsl:with-param instruction is used inside xsl:apply-templates the parameter value is passed to a matching template. If we call another template from the matching one, the value of the parameter is not passed.

Sometime it is useful to have this parameter available to further templates as well. In this case xsl:with-param bears the attribute tunnel with value "yes". If the target template uses xsl:param with the tunnel attribute set to "yes", tunneling of parameters is accomplished.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xsl:apply-templates  select="bbb">
                        <xsl:with-param  name="parA"
                                    select="1"
                                    tunnel="no"/>
                        <xsl:with-param  name="parB"
                                    select="9"
                                    tunnel="yes"/>
                  </xsl:apply-templates>
            </xsl:template>

            <xsl:template  match="bbb">
                  <xsl:param  name="parA"/>
                  <xsl:param  name="parB"/>
                  <bbb-final>
                        <xsl:text>[</xsl:text>
                        <xsl:value-of  select="$parA"/>
                        <xsl:text> - </xsl:text>
                        <xsl:value-of  select="$parB"/>
                        <xsl:text>]</xsl:text>
                  </bbb-final>
                  <xsl:apply-templates  select="ccc"/>
            </xsl:template>

            <xsl:template  match="ccc">
                  <xsl:param  name="parA"
                              tunnel="yes"/>
                  <xsl:param  name="parB"
                              tunnel="yes"/>
                  <ccc-final>
                        <xsl:text>[</xsl:text>
                        <xsl:value-of  select="$parA"/>
                        <xsl:text> - </xsl:text>
                        <xsl:value-of  select="$parB"/>
                        <xsl:text>]</xsl:text>
                  </ccc-final>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>
                  <ccc/>
            </bbb>
      </aaa>
Output

      <bbb-final>[1 - ]</bbb-final>
      <ccc-final>[ - 9]</ccc-final>


Previous chapter: Named-Templates
Next chapter: Stylesheet Functions
Previous page: Difference between parameters and variables
Next page: - - -

Kevin Carr in Stanton

Natural Skin Care and European Soaps
Kevin Carr
Mayor Dave Shawver Stanton
Internetusers


You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here:

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks