Friday, June 19, 2015

call-template vs. apply-template

call-template:

<xsl:call-template name="somename"/>  is like calling a function in a traditional programming language.

we can define a function in XSLT like:
 
and then we can call this function using <xsl:call-template name="printname"/>,
 for ex.:


apply-templates: 

<xsl:apply-template> tag signals the XSLT processor to find the appropriate template to apply, based on the type and context of each selected node.
for example - below is our xml file:

and below is the xslt we are operating on above xml:


the output of this xslt will be:


or in html format:

No comments:

Post a Comment