Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
An
match
attribute of the
If there is more than one
import precedence
and
priority
, as detailed under
If there is no
Node Kind | Action of Built-In Template Rule |
Document node Element node | Call apply-templates to process each child of the selected node, using the mode specified on the call to |
Text node Attribute node | Copy the string value of the node to the result sequence, as a text node. This is done as if the contents of the template were . |
Comment node Processing Instruction Namespace node | No action. |
For the document node and for element nodes, the built-in template rule processes the children of the selected node in document order, matching each one against the available template rules as if the template body contained an explicit
select
attribute. Unlike the situation with explicit template rules, the mode is sticky; it is carried through automatically to the template rules that are called. So if you execute
for an element that has no matching template rule, the built-in template rule will execute
for each of its children. This process can, of course, recurse to process the grandchildren, and so on.
In XSLT 2.0, the built-in template rules not only pass on the mode they were called with, they also pass on their parameters. This is a change from XSLT 1.0.
Parameters
If there are any
Each
If the
as
attribute, then the value of the parameter must match the type specified in this attribute, and if necessary the value is converted to this type using the standard conversion rules described on page 505. In theory it is possible for a parameter value to be converted twice, first to the type defined on the
It is not defined whether the parameter is evaluated once only or whether it is evaluated repeatedly, once for each node in the sequence. If the value isn't needed (for example, because the
select
expression selected no nodes or because none of the nodes matches a template that uses this parameter) then it isn't defined whether the parameter is evaluated at all. Usually this doesn't matter, because evaluating the parameter repeatedly will have exactly the same effect each time. But it's something to watch out for if the parameter is evaluated by calling an extension function that has a side effect, such as reading the next record from a database.
If the name of a child
If the
tunnel=“yes”
, then the parameter is available not only to the immediately called templates, but to templates at any depth in the call stack, provided they declare the parameter with
If there is a child
If there is an
required=“yes”
.