This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Treat any template as a function
- From: Brian Smith <blsmith at blue dot weeg dot uiowa dot edu>
- To: XSL-List at lists dot mulberrytech dot com
- Date: Wed, 19 Dec 2001 20:32:17 -0600
- Subject: [xsl] Treat any template as a function
- Reply-to: xsl-list at lists dot mulberrytech dot com
I am using the EXSLT Function module a lot. But, I'm wondering why it is
necessary. Why can't XSLT processors allow users to call templates using
normal function notation. Is this something that is planned for XSLT
2.0? Personally, I don't see any obvious value in distinguishing between
functions and templates (a template is just a function that returns an
RTF, and an RTF is just a special type of node-set).
For example, the following two stylesheet fragments should, IMO, be
equivilent, given a template like this:
...
<xsl:template name='bls:my-template'>
<xsl:param name='param1'/>
<xsl:param name='param2'/>
</xsl:template>
...
(1)
...
<xsl:variable name='var'>
<xsl:call-template name='bls:my-template'>
<xsl:with-param name='param1' select='...'/>
<xsl:with-param name='param2' select='...'/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select='$var/*'/>
...
(2):
...
<xsl:value-of select='bls:my-template(param1, param2)'/>
...
Along similar lines, has anybody written a stylesheet that can do these
transformations on a stylesheet:
1. Transform all named templates (without match patterns)
into EXSLT functions?
2. Transform all <call-template> elements that call these
functions into <xsl:value-of> elements that cal them?
Thanks,
Brian
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list