i have basic query. have been using xsl:template , use call tempate make recursive calls template. see xsl:function has feasibility make recursive function calls recursive template calls , achieve same. when should xsl:function used , when should xsl:template used. not sure diffence between 2 , when should used. special features of each of them. can please me understand better.
this how replied similar question 3 years ago:
benefits of using
<xsl:function/>
:
composability.
looks great in expression uses parameter, return value or partial application.
readability (compactness) , maintainability.
more loose coupling (does not depend on implicit context node)
can referenced in xpath expression
shortcomings:
parameters identified position (not name)
can impure (can have side effect, such creating new node(s)) , looking @ expression referencing function people may not understand has side effect. possibility of confusion can eliminated if proper naming used.
i tend use
<xsl:function/>
. in cases when function creates new node(s) follow convention of starting local-name string "make", inmakeperson()
.
i can add this:
always when possible use <xsl:function>
.
in xpath 3.0 functions first-class data type of language (aka hof -- higher-order functions). can passed parameters or returned result to/from other functions.
this incredibly powerful leap forward using named templates.
Comments
Post a Comment