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 7036 - bug in test case K2-NameTest-84 ?
Summary: bug in test case K2-NameTest-84 ?
Alias: None
Product: XML Query Test Suite
Classification: Unclassified
Component: XML Query Test Suite (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Frans Englich
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
Depends on:
Reported: 2009-06-21 03:48 UTC by Bogdan Butnaru
Modified: 2010-03-15 12:26 UTC (History)
4 users (show)

See Also:


Description Bogdan Butnaru 2009-06-21 03:48:15 UTC
Hello! I'm using a version of the test suite taken from the CVS about a week ago. I might be misusing it, I apologize if that's the case.

Test case “K2-NameTest-84” (in cat/NameTest.xml) reads:

(: Test: K2-NameTest-84                                  :)
(: Written by: Frans Englich                             :)
(: Date: 2007-11-22T11:31:21+01:00                       :)
(: Purpose: Axis names are reserved function names.      :)
declare default function namespace "";
    declare function element()
(: end test case quote :)

The test case expects the error XPST0003 (i.e., the expression is not a valid instance of the XQuery grammar), but does not cite any spec for that. I fail to find anything relevant in both the XQuery 1.0 and 1.1 (draft) specs.

As far as I can tell, Appendix 3 “Reserved Function Names” (in both specs) refers only to function calls. Furthermore, it does not actually specify an interdiction but an impossibility: it only disambiguates the grammar, which is why there is no error code given.

Production “FunctionDecl” (number 26 in 1.0 and 32 in 1.1) doesn't have the “reserved-function-names” annotation. The extra-grammatical constraint specifies that “it is not legal syntax for a user to invoke functions with unprefixed names which match any of the names in A.3”. (Note that this specifically says “invoking”, not “declaring”, a function.)

By my reading, the query above defines the function “element” in namespace “”, and then goes on and returns the value of “./child::element()” (i.e., the body is a PathExpr consisting of a single AbbrevForwardStep with an ElementTest).

The correct error code would be XPDY0002, since the context element is not defined; however, one supposes that's not what the test case attempts to test. The syntax error expected could only arise if the function's arity would be greater than zero, and it were called with an argument that is not a QName.

Note that while the function cannot be called in the test case as written, a function declared with an unprefixed but reserved name can actually called, for instance as below:

(: example :)
declare default function namespace "";
declare namespace NS = "";
declare function element() { 1 };
(: end example :)

I suggest to change the test to the following:

(: suggestion :)
declare default function namespace "";
declare function element($arg) { $arg };
(: end example :)
Comment 1 Frans Englich 2009-10-14 13:54:41 UTC
I think you're right actually. Saxon, QtXmlPatterns(implemented by me), and X-Hive disagrees with your interpretation, but considering that reserved-function-names doesn't apply to FunctionDecl as you point out, I agree.

Mike, you got an objection or have Bogdan found a slew of (minor) bugs?
Comment 2 Michael Kay 2009-10-14 14:03:34 UTC
Yes, I suspect Bogdan's reasoning is correct.
Comment 3 Frans Englich 2009-10-14 14:29:56 UTC
This should be fixed in CVS.
Comment 4 Tim Mills 2009-10-16 13:41:47 UTC
In the XQTS catalog file for this test (NameText.xml), the scenario for this test is still parse-error, so needs fixing.
Comment 5 Andrew Eisenberg 2009-12-08 00:02:45 UTC
I agree with Tim in comment #5. 
Comment 6 Michael Kay 2010-01-11 22:11:29 UTC
See also bug #8713. I think the spec needs clarifying: there's nothing in App.3 that says it refers only to function calls and not to function declarations, though there is circumstantial evidence elsewhere that that was intended. I don't really care much which way the decision goes.
Comment 7 Michael Dyck 2010-02-17 01:00:41 UTC
According to Bug 8713 comment #3, "Our intent in 1.0 was to disallow such names in both function declarations and invocations. We will revise the 1.0 tests to allow either error or success."
Comment 8 Frans Englich 2010-03-15 12:26:30 UTC
XPST0003 added as baseline in CVS.