xsl-list
[Top] [All Lists]

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

2007-07-21 03:50:59
Now the questions is, is xsl:template name= ... 
able to do something, which xsl:function cannot do?

Depends what you count as "able to do something". For example, a named
template can declare default values for parameters. Does that count?

Please consider the below example:

...

 <xsl:function name="xx:dummy-func" as="node()+">
   <dummy-content/>
 </xsl:function>

 <xsl:template name="dummy-template">
   <dummy-content/>
 </xsl:template>

I am calling a named template, using xsl:call-template. The 
output of this stylesheet is:

<?xml version="1.0" encoding="UTF-8"?>
<result xmlns:xx="http://dummy-ns";>
  <dummy-content/>
</result>

Can we do a similar thing using xsl:function? 

Yes, you can:

<xsl:template match="/">
  <result>
    <xsl:sequence select="xx:dummy-func()"/>   
  </result>
</xsl:template>

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
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>
--~--