Re: [xsl] Re: Designs for XSLT functions (Was: Re: RE: syntax sugar for call-template)

Subject: Re: [xsl] Re: Designs for XSLT functions (Was: Re: RE: syntax sugar for call-template)
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 20 Feb 2001 11:46:59 +0000
Hi Dimitre,

> I see... Then somePrefix:fn() What is different in exsl:function()
> vs. my:func() ??? They seem the same to me.

exsl:function() is a generic function for dynamically calling any
function at all by name.  my:func() is a particular extension function
that I want to call.  So strictly:


is equivalent to:


or to adopt your naming scheme:


>> >> 2.b. Passing parameters by position vs. name
>> >
>> >
>> > fn(QName, p1="Name1 Value1",..., pN="NameN ValueN")
>> >
>> > This allows parameters to be passed by name (as above), 
>> This is a syntax that isn't allowed in XSLT 1.0.  That's not to say
>> that it wouldn't be a useful syntax to have, just that *we* cannot
>> make that change.
> OK,
> But the following is allowed, isn't it? 
> x:fn(QName, "Name1 Value1",..., "NameN ValueN")
> Variations of this allow for passing by name -- only, passing by
> position only, or a mixture of passing by name and passing by
> position.

Yes, and it would be a very interesting way of calling functions, in
particular because the expressions for getting their values could be
constructed as strings.  As Mike pointed out, if you have a static
method like:

  my:func(value1, value2)

then with a exsl:evaluate() function you could do:

  exsl:evaluate("my:func(value1, value2)")

to get the same effect.  That way you can construct anything on the

However, if we *only* have exsl:evaluate() then unless we allow
passing by name within the static method (which I guess is a
possibility), then we won't be able to allow access by name within the
dynamic method.

I personally think that a function for dynamic invocation of functions
would be more helpful.  Your method above is good because, as you say,
you can pass by position or by name (I'm not sure how you get the two
to mix - perhaps you can expand on that?).  This means that unlike the
method that Uche and I were talking about:

  exsl:call('my:func', 'Name1', Value1, 'Name2', Value2)

it could also be applied to existing XPath functions that do not have
a concept of 'named' arguments, only positional ones.  For example,
with your method you could do:

  x:fn('substring-before', '$string', '$char')

Whereas with the method Uche and I were talking about you'd be stuck.



Jeni Tennison

 XSL-List info and archive:

Current Thread