[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
modeattribute 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:dateor 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:
#allFor
<xsl:template>, we can use the valuemode="#all". This specifies that a given template matches all modes. However, if the current mode is"toc", a template withmode="toc"is invoked instead of a template withmode="#all".#currentFor the
<xsl:apply-templates>element, we can use the valuemode="#current"to invoke other templates using the current mode. This effectively uses the current mode as a parameter.#defaultThe
<xsl:apply-templates>and<xsl:template>elements can usemode="#default". The default ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access