[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [exsl] Naming exsl:return/exsl:result (Was: Re: [xsl] Functional programming in XSLT)


Subject: Re: [exsl] Naming exsl:return/exsl:result (Was: Re: [xsl] Functional programming in XSLT)
From: "Lassi A. Tuura" <lat@xxxxxx>
Date: Tue, 20 Mar 2001 19:04:09 +0100

> but how do you propose that a template return such nodes?

My idea was that when RTFs will go away, XSL could also do away with the
distinction of copying and returning node sets.  xsl:copy-of could just
return the node set, not make a new copy of it.  It the context requires
it, the result would be turned into a copy -- e.g. if it is being
inserted as a content of something else, such as the output tree.

I haven't thought through this; it might not be worth the hassle for
xsl:copy-of because of resulting confusion or difficult wordings in the
standard.  However, this change (or a new primitive) has nothing to do
with function result values in itself, it is just as useful even if
exsl:function did not exist.  It should be allowed where xsl:copy-of is
allowed, in particular in xsl:variable, xsl:param and xsl:with-param. 
It could be used to return values from exsl:function too.

For me the need for this primitive arises from removing RTFs -- and
simply has a natural extension to the functions that need to return
values.

Basically, why couldn't I say this?
 <xsl:call-template name="xref-to">
   <xsl:with-param name="node">
     <xsl:for-each select="document('glossary.xml')">
       <xsl:copy-of select="id($target)"/>
     </xsl:for-each>
   </xsl:with-param>
 </xsl:call-template>

It would certainly be possible to turn the <xsl:for-each> into an
exsl:function that uses exsl:return-value, but that is a bit of a waste
when the parameter initialisation is trivial but cannot be expressed as
a `select' attribute (as above).  In such a situation inserting it
directly into with-param would be a lot simpler.  Only: I need to be
guaranteed that I am getting the original nodes so that if I reprocess
them I get the same instances, not new copies.

> If instead you use exsl:function then what was a template becomes a
> function so you can put arbitrarily complex stuff into a single select.
> select="my:function(xxx)" where my:function is defined by one of the
> extension proposals in these threads.

Sure, and that will be nice.

//lat
-- 
Perfection of means and confusion of goals... characterize our age.
	--Albert Einstein

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords
xsl