Re: [xsl] [xslt 2.0] Difference betwen functions and templates

Subject: Re: [xsl] [xslt 2.0] Difference betwen functions and templates
From: Justin Johansson <procode@xxxxxxxxxx>
Date: Thu, 19 Jul 2007 23:44:46 +0900
Mukul,

Thanks for your contribution to this lively discussion.

>I feel, having xsl:template in XSLT 2.0 is very important, for XSLT
>2.0 to be backward compatible with XSLT 1.0.

It is not a question of backward compatibilty.

xsl:template is the very essence of XSLT as opposed to XQuery.

Take away xsl:template's from XSLT and you essentiallly have
XQuery availalble to you in a lesser XML-based syntax.

The whole model of XSLT is to present to the programmer
a series of nodes which can be matched to a path-match
expression and then have automatic invocation of a rule to
prepare (return) a result (nodal) series (aka sequence) upon
recursive descent of the input XML tree.

This is important in anyone's undertanding of XSLT :-

What the XSLT processor does for you, and saves you the
trouble of, is to do a recursive descent of the source XML
tree and match rules, which you declare via xsl:template,
to be fired (much like callbacks in C/C++) whenever
the recursive descent of the source tree encounters
an XML node which matches the pattern you declared via
xsl:template match=

XQuery has no facility to do this.  XQuery is dumbed down XSLT,
though has some facilities which are important when dealing
with larger databases.

XQuery, exists soley for the reason of an attempt to by-pass an
XML-based programming language syntax for the processing XML.

I am sure that Michael Kay would reply in a more concise manner than myself.





The bottom line is that named templates and functions are essentially
>> the same thing and it would have been possible for XSLT 2.0 to do
>> away with either xsl:call-template or xsl:function.

>They probably look similar, but IMHO both are useful members of XSLT
>2.0. As you also said, xsl:function can be called from within an XPath
>expression (and, this is a very important difference) while
>xsl:template cannot be.

>I feel, having xsl:template in XSLT 2.0 is very important, for XSLT
>2.0 to be backward compatible with XSLT 1.0.

>And of course, xsl:function is really beneficial, as also stated by
>others in this thread.
>
>-- 
>Regards,
>Mukul Gandhi

Justin Johansson
Schema-aware XSLT evangelist

Current Thread