<xsl:call-template name=”qname” > </xsl:call-template>
The xsl:call-template element is used to invoke a template by name. By invoke, we mean that the named template is called and applied to the source document. If a template does not have a name, it cannot be called by this element.
The xsl:template element is used to create a template. You can name a template by using the name attribute of the xsl:template element. Further, the name called by the mandatory name attribute of the xsl:call-template element must match the name specified by the name attribute of the xsl:templateelement. Complicating matters is the fact that a template is not required to have a name.
A template is only required to have either a name or match attribute. (It can have both.) Ideally, each template will have a unique name. However, if a name is repeated, then the two templates must have a different import precedence (refer to the xsl:import element), otherwise it is an error.
An xsl:call-template element cannot directly return a result. You need to enclose the xsl:call-templateelement inside an xsl:variable element which serves as the current output destination (see code example).
The xsl:call-template element can contain zero or more xsl:with-param elements. It cannot contain any other XSLT elements. These xsl:with-param elements will only be evaluated if there is a matching xsl:param element in the template being called. If there is no such match, then the xsl:with-paramelement is simply ignored.
This is not a self-closing element. The separate closing element is mandatory.
The mandatory name attribute is the unique qname of the template that you wish to invoke. A qname is a qualified name that is composed of an optional namespace prefix, a colon which is only present if there is a prefix, and a mandatory XML name (for example, xsl:zipcode or zipcode).
This name must match the name used by the name attribute of the xsl:template element that was used originally to create the template.
Scroll to Top