Using xsl:apply-templates with xsl:with-param

Subject: Using xsl:apply-templates with xsl:with-param
From: "Ron Ten-Hove" <rtenhove@xxxxxxxxx>
Date: Mon, 15 May 2000 13:09:27 -0700
How is xsl:with-param supposed to work from within an xsl:apply-templates
element?  The recommendation doesn't seem to actually spell it out, other
that saying it is allowed.  Consider the following:

XSL STYLESHEET:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">
    <xsl:output indent="yes"/>

    <xsl:template match="/">
        <root>
            <xsl:apply-templates>
                <xsl:with-param name="param">List</xsl:with-param>
            </xsl:apply-templates>
        </root>
    </xsl:template>

    <xsl:template match="chapter">
      <xsl:param name="param">Unset</xsl:param>
      <chap>
        <xsl:attribute name="title"><xsl:value-of
select="@name"/></xsl:attribute>
        <xsl:attribute name="cat"><xsl:value-of
select="$param"/></xsl:attribute>
      </chap>
    </xsl:template>

    <xsl:template match="text()" />
</xsl:stylesheet>

XML SOURCE:
<?xml version="1.0"?>
<doc>
  <chapter name="The beginning">
    Alpha.
  </chapter>
</doc>

Both XT and SAXON give the same result:

<?xml version="1.0" encoding="utf-8" ?>
<root>
   <chap title="The beginning" cat="Unset"/
</root>

the "cat" attribute value is "Unset", rather than what I'd naively expect:
the
parameter value supplied by the apply-templates element.  How are parameters
supplied by xsl:apply-templates elements to be treated?

-Ron


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


Current Thread