Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Note that the instruction doesn't examine all template rules with lower precedence than the current rule. For an example that illustrates this, see
Figure 6-4
on page 360. If the current template rule is in module C on that diagram, then
The specification defines what this means in terms of the import tree. If a stylesheet module A includes another module B using
It is possible to specify parameters to be supplied to the called template, using
required=“yes”
, then a runtime error occurs if no value is supplied for that parameter.
Usage and Examples
The intended usage pattern behind
One stylesheet,
a.xsl
, contains general-purpose rules for rendering elements. For example, it might contain a general-purpose template rule for displaying dates, given as follows:
A second stylesheet,
b.xsl
, contains special-purpose rules for rendering elements. For example, you might want it to display dates that occur in a particular context in the same way, but in bold face. It could be written as:
However, this involves duplicating most of the original template rule, which is a bad idea from a maintenance point of view. So, in
b.xsl
we could import
a.xsl
, and write instead:
Note that the facility only allows a template rule to invoke one of lower
import precedence
, not one of lower
priority
. The import precedence depends on how the stylesheet module was loaded, as explained under
timeline/date
template rule is in a stylesheet module that directly or indirectly imports the
date
template rule. It will not work, for example, if they are in the same module but defined with different priority. In this respect,
In many situations the same effect can be achieved equally well by giving the general-purpose template rule a name and invoking it from the special-purpose template rule by using
tag for any source element that has an
anchor
attribute.” Rather than modifying every rule in the existing stylesheet, this can be achieved by defining a new stylesheet module that imports the original one, and contains the single rule:
There is a more complete example of the use of
See Also
xsl:apply-templates
The
Changes in 2.0
The
mode
attribute may now take the value
#current
to continue processing in the current mode.