> > Can you please estimate the value reported in xsl:message in
> > a
following stylesheet?
> > Saxon 9.1 reports value 2.
> > My expectation is
1.
> > If 2 is correct output then can you please justify it.
>
> On the
first call of p:test, neither parameter has a value. So $index
> defaults to
1, and $value defaults to 1.
>
> On the second call of p:test, $index has a
value (2). No value has been
> supplied for $value, so it defaults to $index,
which is 2. This is the value
> displayed.
>
> Perhaps this is the
relevant sentence in the spec (section 10.1.2):
>
> <quote>
> Equally,
any default value is local to the template: specifying a default
> value for
a tunnel parameter does not change the set of tunnel parameters
> that is
passed on in further template calls.
> </quote>
Thank you. That was very
instructively.
I understand and accept this logic now, however
in my opinion
this design is unnatural from the
perspective of genesis of tunnel
parameters.
In xslt 1.0 one would write:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://www.nesterovsky-bros.com">
<xsl:template match="/">
<xsl:call-template name="p:test"/>
</xsl:template>
<xsl:template
name="p:test">
<xsl:param name="index" select="1"/>
<xsl:param
name="value" select="$index"/>
<xsl:choose>
<xsl:when
test="$index < 2">
<xsl:call-template name="p:test">
<xsl:with-param name="index" select="$index + 1"/>
<xsl:with-param
name="value" select="$value"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:message select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
I
thought the driving force for the introduction of tunnel
parameters was a
desire to allow passing $value implicitly.
My simplified understanding of
tunnel parameters was that
engine passes them behind the scene as if
inserting
<xsl:with-param name="value" select="$value"/>
--
Vladimir
Nesterovsky
http://www.nesterovsky-bros.com
> > <xsl:stylesheet
version="2.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >
xmlns:xs="http://www.w3.org/2001/XMLSchema"
> >
xmlns:p="http://www.nesterovsky-bros.com">
> >
> > <xsl:template
match="/">
> > <xsl:call-template name="p:test"/>
> > </xsl:template>
> >
> > <xsl:template name="p:test">
> > <xsl:param name="index"
as="xs:integer" select="1"/>
> > <xsl:param name="value" tunnel="yes"
as="xs:integer"
> > select="$index"/>
> >
> > <xsl:choose>
> >
<xsl:when test="$index lt 2">
> > <xsl:call-template name="p:test">
> > <xsl:with-param name="index" select="$index + 1"/>
> >
</xsl:call-template>
> > </xsl:when>
> > <xsl:otherwise>
> >
<xsl:message select="$value"/>
> > </xsl:otherwise>
> >
</xsl:choose>
> > </xsl:template>
> >
> > </xsl:stylesheet>
|