xsl:with-param and xsl:apply-templates

Subject: xsl:with-param and xsl:apply-templates
From: Norman Walsh <ndw@xxxxxxxxxx>
Date: 25 Oct 2000 09:20:14 -0400
Hello world,

I figure there's about a 99% chance that I'm overlooking something
really, really obvious, but that's one of the problems with things
that are really, really obvious: they're so blasted easy to overlook.

Saxon, XT, and Xalan all do something other than I expect with the
following stylesheet, which leads me to believe I've forgotten
something about XSLT. What is it?

Assuming a test document of "<doc><p>foo</p></doc>", I expect
the xsl:message to produce "??? 1, doc, Rubble", but it produces
"??? 0, doc, Flintstone". Why?

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

  <xsl:output method="html"/>

  <xsl:template match="/">
    <xsl:variable name="doc" select="*[1]"/>
    <head>
      <xsl:call-template name="head.content">
        <xsl:with-param name="node" select="$doc"/>
      </xsl:call-template>
    </head>
  </xsl:template>

  <xsl:template name="head.content">
    <xsl:param name="node" select="."/>
    <title>
      <xsl:apply-templates select="." mode="title.refX">
        <xsl:with-param name="text-only" select="'1'"/>
        <xsl:with-param name="FRED" select="'Rubble'"/>
      </xsl:apply-templates>
    </title>
  </xsl:template>

  <xsl:template match="*" mode="title.refX">
    <xsl:param name="FRED" select="'Flintstone'"/>
    <xsl:param name="text-only" select="'0'"/>
    <xsl:message>
      <xsl:text>??? </xsl:text>
      <xsl:value-of select="$text-only"/>
      <xsl:text>, </xsl:text>
      <xsl:value-of select="name(.)"/>
      <xsl:text>, </xsl:text>
      <xsl:value-of select="$FRED"/>
    </xsl:message>
  </xsl:template>

</xsl:stylesheet>

-- 
Norman.Walsh@xxxxxxxxxxxx | If we lived alone in a featureless desert
XML Technology Center     | we should learn to place the individual
Sun Microsystems, Inc.    | grains of sand in a moral or aesthetic
                          | hierarchy.--Michael Frayn


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


Current Thread