Re: [xsl] xsl:function vs. xsl:template

Subject: Re: [xsl] xsl:function vs. xsl:template
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Wed, 19 Nov 2008 14:44:53 +0100 (CET)
Felix Geller wrote:

  Hi,

>    how does the experienced XSLT 2.0 programmer decide on whether
> to use a xsl:function or a (named) xsl:template?

  My rule of thumb, when there is no other way to decide, is to write a
template if it creates new nodes, and a function elsewhere.

  Another point, in favour of functions, is if it has to be used (or if
it is just more convenient) in an XPath expression (for instance
functions that will typically be used within predicates.)

  And a determinant point is when you want to be able to configure the
call in many ways (passing a lot of different parameters) while being
able to have default values for most of them.  Using a named template
provides something similar to the keyword parameters in Lisp.

  But this is far from being strict rules, and this has more to do with
experience and feeling.

  Regards,

-- 
Florent Georges
http://www.fgeorges.org/

Current Thread