xsl-list
[Top] [All Lists]

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

2008-11-19 08:45:16
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/
























      


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>