Welcome to our free XSLT 1.0 and XPath 1.0 tutorial. This tutorial is based on Webucator's XSLT 1.0 and XPath 1.0 Training course.

Contact Us or call 1-877-932-8228


The xsl:call-template element is used to call a named template. The following example illustrates how it is used.

Code Sample:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/">
		<xsl:call-template name="StartHTML"/>
	<xsl:template name="StartHTML">
					<xsl:apply-templates select="beatles/beatle">
						<xsl:sort select="lastname"/>
	<xsl:template match="beatle[not(@real='no')]">
		<li style="color:blue;"><xsl:apply-templates/></li>
	<xsl:template match="beatle">
		<li style="color:red; text-decoration:line-through">
	<xsl:template match="name">
		<xsl:value-of select="lastname"/>,
		<xsl:value-of select="firstname"/>

The template being called is named StartHTML:

<xsl:template name="StartHTML">

The xsl:call-template tag also takes the name attribute, which simply matches the name of the template started above:

<xsl:call-template name="StartHTML"/>

The called template inherits the context from the calling template. In this case the calling template matched the root node. Therefore, the root node will be the context node for all relative XPaths in the called template.


This tutorial is based on Webucator's XSLT 1.0 and XPath 1.0 Training Course. We also offer many other XML Training courses. Sign up today to get help from a live instructor.