completed A-627-02: "clarify what the text means"

> ACTION A-627-02: Michael Dyck to review bug #29277 and clarify what the
> text means. ETA 2016-01.

(Despite what the action item says, I'm not reviewing the whole of Bug

Specifically, "the text" is the paragraph in XPath 3.x section
(Evaluating Static and Dynamic Function Calls) that the minutes
characterize as "difficult to interpret".  To set the stage,
     FC is a (static or dynamic) function call,
     F is the function to be called,
     SC is FC's static context, and
     DC is the dynamic context against which FC is being evaluated.

Then, 5.b.i says:
     If F's implementation is implementation-dependent
     (e.g., it is a built-in function or external function
     or host-language-dependent function,
     or a partial application of such a function):

       * F's implementation is invoked with the converted argument
         values using the contexts it is associated with in F.  If
         these contexts are absent in F, it is associated with SC and DC.

       * ...

(I'll refer to these as the "If paragraph" and the "bullet paragraph".)

At meeting 627, I was puzzled by the bullet paragraph's talk of
associated contexts.  To make sense of this, I needed to go back to
the definition of 'function' in the Data Model, which states that:
     an implementation-dependent function implementation [...] is
     optionally associated with both a static and a dynamic context.

This concept of associated contexts was proposed in 2012 by Ghislain
Fourny in the message:

The proposed change to the bullet paragraph is edit #4 in the above
message. However, what Ghislain proposed isn't what we have now. Here's
a comparison, using curly braces around the differing text:

Ghislain's proposed text:
     F's implementation is invoked with the converted argument values
     {and with respect to}
     the contexts it is associated with in F.
     If {it is not associated with any contexts},
     it is {invoked with respect to} SC and DC.

current text:
     F's implementation is invoked with the converted argument values
     the contexts it is associated with in F.
     If {these contexts are absent in F},
     it is {associated with} SC and DC.

The first difference was probably just an editorial change, but I think
the second and third differences were unintentional: the sentence
   "If these contexts are absent in F, it is associated with SC and DC."
does appear in Ghislain's proposal, but in edit #3 (re partial function
application), not edit #4. So I think the second sentence in the current
bullet paragraph is there due to a copy-and-paste error. Changing it to
what Ghislain wrote would be an improvement.


However, that change wouldn't address Mike Kay's concern (raised in, which
I believe can be paraphrased thusly:
     A user-defined stylesheet function in XSLT (i.e., an <xsl:function>)
     is (from XPath's POV) a "host-language-dependent function", and
     therefore the condition in the "If" paragraph is true, and therefore
     the bullet paragraph applies. However, that para seems to indicate
     that the function's implementation is invoked with the SC and DC
     of the *call*, which it isn't.

One possible way out of this is that the bullet paragraph *doesn't*
invoke the function's implementation with the SC and DC of the call
if the function's implementation already has associated contexts.
So the XSLT spec could assert that, in terms of the Data Model,
a stylesheet function is a function with an implementation-defined
implementation that is associated with such-and-such contexts.

One problem with this approach is that it would contradict XPath 2.1.2
(Dynamic Context), which says:
     Named functions can include functions with implementation-dependent
     implementations; these functions do not have a static context or a
     dynamic context of their own.
I'm not sure if that *needs* to be true, or just happens to be true
so far.  If the latter, we could just remove it.

Another approach would be to modify the bullet paragraph to be more
laissez-faire, something like:
     F's implementation is invoked. The processor makes the following
     information available to that invocation:
       * the converted argument values; and
       * a static context and dynamic context.
         If the implementation is associated with a static and dynamic
         context, then these, otherwise SC and DC.
     Note: Whether and how this information is used by the function is,
     of course, entirely up to semantics that are not defined by this

(I'm not thrilled with this particular wording, but it at least makes
clear that the XPath spec is *not* dictating the context against which
a stylesheet function is evaluated.)

(Also, the XPath spec could maybe be more authoritative than the above
when it comes to *built-in* (i.e., F+O) functions, but I'm not sure it
needs to be.)

I think I prefer approach (2).


Received on Monday, 4 January 2016 05:19:32 UTC