February 26, 2021
Hot Topics:


  • By Sam Huggill
  • Send Email »
  • More Articles »

In XSL, you can encapsulate code in a "template". This acts rather like a function, and can be very useful. Here is a typical template:

<xsl:template name="demo"match="people/person">    <xsl:value-of select="@name"/>    <xsl:value-of select="@email"/></xsl:template>

You can call a template using the <xsl:call-template> tag.

We can now rework our loop to use a template:

<xsl:template name="person"match="people/person">    <xsl:value-of select="@name"/>    <xsl:value-of select="@email"/></xsl:template><xsl:template match="/"><xsl:for-eachselect="people/person">    <xsl:call-template name="person"/></xsl:for-each>

Page 4 of 6

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date