Name
xsl:template
Synopsis
<xsl:template match = "pattern
" priority = "number
" name = "QualifiedName
" mode = "QualifiedName
"> <! -- (xsl:param*, template) -- > </xsl:template>
The xsl:template
top-level element is the key to all of XSLT. Confusingly, the
xsl:template
element itself is
not a template. Rather, it contains a template. The entire
xsl:template
element is called
a template rule. The match
attribute contains a pattern
against which nodes are compared as they’re processed. If the
pattern matches a node, then the template (i.e., the contents of
the template rule) is instantiated and inserted into the output
tree.
Attributes
match
, optionalA pattern against which nodes can be compared. This pattern is a location path using only the
child
,attribute
, anddescendant-or-self
axes or a combination of several such location paths.priority
, optionalA number. If more than one template rule with the same import precedence matches a given node, the one with the highest priority is chosen. If this attribute is not present, then the template rule’s priority is calculated in the following way:
Template rules with match patterns composed of just an element or attribute name (e.g.,
person
or@profession
) have priority 0.Template rules with match patterns composed of just a
processing-instruction(
'target
')
node test have priority 0.Template rules with match patterns in the form
prefix
:*
have priority -0.25.Template rules with match patterns that just have a wildcard node test (
*
,@*
,comment() ...
Get XML in a Nutshell, 3rd 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.