[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Designs for XSLT functions (Was: Re: RE: syntax su

Subject: Re: Designs for XSLT functions (Was: Re: RE: syntax sugar for call-template)
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 19 Feb 2001 08:58:54 +0000
xslt function template
Hi Uche,

> As it is, I am very interested in experimental implementation of
> these ideas in 4XSLT.

That's great :)

> I hope that I and my fellow implementors who are interested in these
> ideas can all agree on a single NSRef for this set of extensions. I
> have the opentechnology.org domain available. If this is amenable,
> how about
>
> xmlns.opentechnology.org/common-xslt-extensions

Ah good, I was hoping someone would come up with a namespace :) That
one looks fine by me, but if there are any other offers (or objections
to the above) it would be great to have them on the table.

>> Arguments for xsl:template include:
>> i.  it already exists
>> ii. it might then be possible to have a template that was used both
>>     with normal xsl:call-template syntax and as a function (though
>>     it's arguable whether this is desirable).
>
> Well, the nice thing about this is that it would be easy to call
> existing named templates with the new syntax. Also, one could set up
> a single template for import into both regular transforms and ones
> that use exsl:function.

Aside from the fact that there would be a massive conflict with your
stated preference for *only* exsl:return.  If only exsl:return were
allowed, there would be no way to have a regularly called template and
a function template.

>> 1.b. Top-level declaration vs. declaration within xsl:script
>
> As they say in teen movies: "don't even go there".
>
> To be more precise, I vote firmly for top-level. Surprise surprise.
> Perfectly legal under XSLT 1.0, so why not?

I admit that the rationale for xsl:script is weak if we're only
talking about user-defined functions in XSLT.  One plausible rationale
would be, if we have functions declared with xsl:template, that it
could indicate which xsl:template elements have to comply with the
function rules (e.g. contain exsl:return, not generate any nodes).

*If* the xsl:script element is accepted into the XSLT 1.1 canon
(leaving aside whether it should be or not), I think it is more
logical to place function definitions in XSLT in xsl:script than at
the top level, so that it mirrors the definitions of functions in
other languages. It would also allow XSLT-defined functions to act as
a fallback when the implementations in other languages have failed (as
long as implementers implement support for exsl:xslt as an xsl:script
language).

> But I do think we should allow RTFs as follows:
>
> <exsl:function name="my:func">
>   <xsl:choose>
>    <xsl:when test="$i-want-my-rtf">
>     <exsl:return>
>      foo
>     </exsl:return>
>    </xsl:when>
>    <xsl:otherwise>
>     <exsl:return select="'foo'" />
>    </xsl:otherwise>
>   </xsl:choose>
> </exsl:function>


>> 2. Calling Functions
>> --------------------
>> 
>> 2.a. exsl:function() vs. my:func()
>
> I think we can have both, but I'd rename exsl:function to exsl:call.

Ah good, I didn't like exsl:function() as a name.

>> 2.b. Passing parameters by position vs. name
>
> Again allow both, but this time by allowing tricks with exsl:call.
>
> The first exsl:call parameter is the function qname. An even number
> of further parameters is permitted, and if so, these are the named
> parameters.

So exsl:call() would *always* take named parameters - always have an
odd number of arguments in total - the function name and then paired
parameters? Whereas my:func() *always* passes parameters by position
(and could therefore have any number of arguments). (Just wanted to
make that clear - I think that allowing both position and name in the
same kind of call will lead to trouble.)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.