[2.0] Important Differences in XSLT 2.0

There are some changes to the way parameters and modes work in XSLT 2.0. We’ll cover those here. To summarize, the key differences are:

  • The mode attribute features three new values: #all, #current, and #default.

  • If you pass a parameter to a template, and that parameter is not defined in that template, an XSLT 2.0 processor will give you an error message and stop. In XSLT 1.0, the undefined parameters were simply ignored.

  • XSLT 2.0 adds the attribute required="yes" to define that a value must be passed for a parameter.

  • You can specify the datatype and/or the structure of a parameter. If a parameter must be an xs:date or a sequence of at least one element, you can specify that.

  • XSLT 2.0 defines a new kind of parameter called a tunnel parameter. Tunnel parameters help you avoid sloppy coding practices that you were often forced into with XSLT 1.0.

New values for the mode attribute

In XSLT 2.0, there are three new values for the mode attribute:


For <xsl:template>, we can use the value mode="#all". This specifies that a given template matches all modes. However, if the current mode is "toc", a template with mode="toc" is invoked instead of a template with mode="#all".


For the <xsl:apply-templates> element, we can use the value mode="#current" to invoke other templates using the current mode. This effectively uses the current mode as a parameter.


The <xsl:apply-templates> and <xsl:template> elements can use mode="#default". The default ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.