XML technologies / XSLT / Introduction to XSLT 2.0 / XSLT and XPath – round three / Variables and parameters / Tunneling through default rules

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 3.)

With named templates, tunneling variables is straightforward because the stylesheet author fully controls which template is called, when, from where and with which parameters. This is less predictable with xsl:apply-templates and parameters passed at the same time. This calling method adapts flexibly to the source document’s structure. A call with parameters may therefore fail to reach a template rule capable of accepting them.

Chapter one already mentioned the XSLT processor and its implemented default rules for different node types. For elements and the document node, the default rule is:

<xsl:template match="*|/">
  <xsl:apply-templates/>
</xsl:template>

No parameter passing is shown, but this is not an actual template rule. Default rules’ parameter behavior deserves attention: XSLT 1.0 and 2.0 differ here.

To avoid misunderstanding, no tunnel attribute is required on the passed parameter. All parameters tunnel through default rules independently of this attribute.

   

back to top