xsl:template
Defines a processing rule for source elements or other nodes of a particular type.
Category: declaration
Content: (
xsl:context-item?
, xsl:param*
, sequence-constructor
)
Permitted parent elements:
xsl:package
; xsl:stylesheet
; xsl:transform
; xsl:override
Attributes
|
|
Pattern to identify the type of node to be processed. The most common form of pattern is simply an element name. However, more complex patterns may also be used: the syntax of patterns is given in more detail in XSLT Pattern Syntax. The following examples show some of the possibilities:
|
||||||||||||||||||||||||||
|
|
If this is present, the template may be
invoked directly using xsl:call-template. The |
||||||||||||||||||||||||||
|
|
If there are several
|
||||||||||||||||||||||||||
|
|
If this is present, the template will only be
matched when the same mode is used in the invoking xsl:apply-templates element. The value can be
a list of mode names, indicating that the template matches more than one mode;
this list can include the token |
||||||||||||||||||||||||||
|
|
Defines the required type of the result. The
result of evaluating the sequence constructor is converted to this required type
using the function conversion rules. The default is
|
||||||||||||||||||||||||||
|
|
New in XSLT 3.0. Determines the
potential visibility of the component corresponding to this template; the
default is |
Notes on the Saxon implementation
The extension attribute saxon:explain can be used on an
xsl:template
element. If the attribute has value
yes
, then at compile time Saxon outputs (to the standard error
output) a representation of the optimized expression tree for that template.
Examples
A simple XSLT template for a particular element. This example causes all
<ptitle>
elements in the source document to be output
as HTML <h2>
elements.