Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

One template calls another template

File: Data.xml <wine grape="Cabernet">   <winery>shop 1</winery>   <product>product 1</product>   <year>1996</year>   <price>11.99</price> </wine> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:output method="xml" omit-xml-declaration="yes" indent="no" />   <xsl:template name="boldIt">     <b>       <xsl:apply-templates />     </b>   </xsl:template>   <xsl:template match="winery">     <p>       <xsl:call-template name="boldIt" />     </p>   </xsl:template>   <xsl:template match="product">     <p>       <xsl:call-template name="boldIt" />     </p>   </xsl:template>   <xsl:template match="year | price">     <p>       <xsl:apply-templates />     </p>   </xsl:template>    </xsl:stylesheet> Output:   <p><b>shop 1</b></p>   <p><b>product 1</b></p>   <p>1996</p>   <p>11.99</p>