Re: [xsl] Template matching on tunnelled variables

Subject: Re: [xsl] Template matching on tunnelled variables
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 17 Feb 2012 08:48:57 +0000
On 17/02/2012 04:27, ihe onwuka wrote:
AFAIK this doesn't work. Why?


Are you asking: why cannot I refer to the value of a tunnel parameter within the match pattern of a template?

If so, I agree it would be useful, but the design would be awkward. We would have to decide whether the variable needs to be declared in the xsl:param elements. If so, having a variable reference before the variable declaration would feel strange. If not, allowing a reference to an undeclared variable in the match pattern but not in the template body would feel strange. It's also difficult to introduce retrospectively because a variable in the match pattern is currently defined to refer to global variables.

It would also prevent some optimizations, which might be important to some implementors. Currently during the course of a single transformation, if you do apply-templates twice on the same node in the same mode, the same template rule is matched each time; this invariant would no longer hold. Since XSLT performance depends critically on being smart in the way template pattern matching works, this could be significant (though not for Saxon).

Michael Kay
Saxonica

Current Thread