[Bug 9139] [XPath 2.1] Dynamic function calls and context

http://www.w3.org/Bugs/Public/show_bug.cgi?id=9139





--- Comment #9 from Michael Kay <mike@saxonica.com>  2010-03-03 20:52:35 ---
>I think that's pretty much covered by the rule: "During evaluation of a function body, the static context and dynamic context for expression evaluation are defined by the module or expression in which the function is declared, which is not necessarily the same as the context in which the function is called."

Except that functions like static-base-uri() aren't "declared". The suggestion
is that if I do

module "a.xq";

declare variable $f as (function() as xs:string) := fn:static-base-uri#0;

module "b.xq";

$f()

then the result should be "a.xq".

I can't say I'm especially comfortable with this: it seems to require some
special-casing. Normally static-base-uri() returns the static base URI of the
caller, and I think I would expect that if $f is bound to static-base-uri#0,
then $f() would also return the static base URI of the caller.

A more important case is perhaps functions like name():

let $myname := if (xxxx) then name#0 else local-name#0

<x/>/$myname()

If the context item is bound to anything here, I think I would expect it to be
bound at the point the function is called, not at the point where $myname is
declared.

Perhaps it's just too much of a pitfall and we should just disallow binding of
context-dependent functions to function items.


-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Wednesday, 3 March 2010 20:52:37 UTC