<c:template
name? = eqname
visibility? = "public" | "private" | "final" | "abstract" | "hidden"
match? = pattern
mode? = "#all" | (eqname | "#default")+
as? = type_name >
<!-- Content: (c:param*, sequence-constructor) -->
</c:template>
Defines a named template or template rule.
- Category
- declaration
- Permitted parent elements
c:module
c:override
c:package
Attributes
as |
The return type. |
match |
A pattern expression. |
mode |
A space separated list of either eqname or "#default"; or "#all". Unprefixed qualified names are in the null namespace. |
name |
The name of the template. |
visibility |
Specifies how the current component can be used in other (using) packages. |
In addition to the attributes in the preceding table, there are a number of standard attributes that may appear on any XCST element.
Example: Matching object
<c:template match='Order o and { CountryCode: "US" }'>
<!-- variable 'o' can be used here -->
</c:template>
Example: Matching nodes
<c:template match='XElement el && el.Name == "html"'>
<!-- variable 'el' can be used here -->
</c:template>
Note: Differences with xsl:template
c:template
is either rule or named, not both.
Error Conditions
It is a compilation error if both attributes name
and match
are present.
It is a compilation error if the name
attribute uses a reserved namespace, except the name c:initial-template
.
It is a compilation error if the mode
attribute is present when the name
attribute is used.
It is a compilation error if the visibility
attribute is present when the match
attribute is used.
It is a compilation error if a named template has visibility='abstract'
and the content of the element, excluding any c:param
elements, is non-empty.