The <xsl:call-template> Element: Using Named Templates

One of the attributes of the <xsl:template> element is name, which you use to give a name to the template. For example, if I have a literal result element consisting of two <BR> and two <HR>HTML elements that I use to create a vertical separator in HTML documents, as follows:

<BR/> 
<HR/> 
<BR/> 
<HR/> 

then I can create a template named “separator” with this literal result element this way:

<xsl:template name="separator"> 
    <BR/> 
    <HR/> 
    <BR/> 
    <HR/> 
</xsl:template> 

This is a named template—all you have to do is assign a name to the name attribute of an <xsl:template> element, and you have a named template.

Note that this template is not set up to match anything in particular. To invoke this ...

Get Inside XSLT 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.