This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 14996 - [FO30] function-lookup, function-arity, function-name
Summary: [FO30] function-lookup, function-arity, function-name
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.0 (show other bugs)
Version: Member-only Editors Drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-29 15:24 UTC by Tim Mills
Modified: 2011-12-06 22:07 UTC (History)
0 users

See Also:


Attachments

Description Tim Mills 2011-11-29 15:24:50 UTC
In WG meeting #491 (2011-11-15), it was decided that:

DECISION: To close bug #14330 with the following resolution:
1. function items can refer to context-independent built-in functions
2. function items can not refer to context-dependent built-in functions
3. you can create an inline function to wrap a context-dependent
built-in function

Will referencing a context-dependent built-in function raise err:XPST0112, or will a new error be created?

16.1.1 fn:function-lookup

The first example  

    fn:function-lookup(xs:QName('fn:contains'), 2)('aa', 'a')

makes a call to function-lookup which would return a context-dependent built-in function.

This funciton will now need to raise a dynamic error (i.e. an error other than XPST0112).  Note that the function doesn't currently handle the case of focus-dependent functions.

16.1.2 fn:function-name

The first example 

    The expression fn:function-name(fn:contains#2) returns fn:QName("http://www.w3.org/2005/xpath-functions", "fn:contains").

references a context-dependent built-in function.

16.1.3 fn:function-arity

The first example 

    The expression fn:function-arity(fn:contains#2) returns 2.

references a context-dependent built-in function.
Comment 1 Michael Kay 2011-11-29 18:28:41 UTC
Yes, you are right, I failed to spot that our decision on context-dependent functions invalidated these examples.
Comment 2 Tim Mills 2011-12-04 20:48:05 UTC
I'd like the following to be considered.  Rather than it being an error to reference a context or focus dependent function, instead make it an error to invoke/apply such a function reference.  This would avoid having to add an error condition for function-lookup.

It  would also mean that function-lookup, function-arity and function-name functions could operate on any function.  There may well be other functions not yet defined (e.g. Is-function-context-sensitive) which could usefully operate on all function items, and the current ruling precludes them.
Comment 3 Michael Kay 2011-12-05 09:13:28 UTC
I guess a natural development of this idea is to make context-sensitivity a kind of function annotation, and provide methods to interrogate the annotations of a function.
Comment 4 Tim Mills 2011-12-05 09:26:45 UTC
It might also be useful to be able to mark an argument as being the context item in a user defined function, for example, to indicate that $implicit-context-item is an implicit argument of '.' in the following.

declare function local:foo($implicit-context-item as item(), $arg2)
{
  number($implicit-context-item) + $arg2
}

//bar/local:foo(8)

or alternatively, permit use of the context item in user defined functions

e.g.

declare function local:foo($arg2)
{
  concat(string(), $arg2)
}

//bar/local:foo(" element")

causing local:foo to be annotated as being context-dependent.
Comment 5 Michael Kay 2011-12-06 22:07:32 UTC
The incorrect examples will be fixed.

The WG resolved that function-lookup applied to a context-dependent function would succeed (returning the function), but that subsequent invocation of the function would fail with a dynamic error.