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 6272 - [XQuery11] Context item declaration
Summary: [XQuery11] Context item declaration
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.0 (show other bugs)
Version: Working drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-04 14:54 UTC by Michael Kay
Modified: 2010-02-13 21:02 UTC (History)
1 user (show)

See Also:


Attachments

Description Michael Kay 2008-12-04 14:54:41 UTC
This relates to the 3 December public WD.

In 4.16 Context Item Declaration:

(a) The text doesn't say what happens if there is no context item declaration. XQuery 1.0 behaviour should apply, that is, there may or may not be a context item and it may have any type.

(b) The text doesn't say what happens if there is a context item declaration, and it specifies "external" with no default value, and no context item is supplied by the environment. Is it an error? (or is it only an error if the query then relies on the context item?). I think that it should be mandatory to supply a context item in this situation.

(c) "If a ContextItemDecl occurs after an expression that relies on the initial context item": it's not clear how to interpret "after" when multiple modules are involved, especially as the context item declaration affects the whole query, not just the module in which it appears. I think that the "after" should be dropped: the rule should apply if any expression relies on the initial context item, wherever it appears.

(d) The fact that the context item declaration has global (cross-module) scope affects the ability to do separate compilation of modules. I think it would be better to allow a context item declaration in each module that references the initial context item, but to allow no initializer in a library module (only a declared type).

(e) The first example appears to be incorrect against the grammar (declare context item as element(env:Envelope)) - it includes neither an initializer or the keyword "external". Perhaps this syntax should be legitimate, creating five options:

   (1) no context item declaration: there may or may not be a context item, there is no default, if supplied it may have any type

   (2) declare context item as xs:integer: there may or may not be a context item, there is no default, if supplied it must be an integer

   (3) declare context item as xs:integer := 3: there is always a context item and its value is always 3.

   (4) declare context item as xs:integer external: there is always a context item and it is always an integer; its value MUST be supplied by the caller

   (5) declare context item as xs:integer external := 3: there is always a context item and it is always an integer; if it is not supplied by the caller then its value will be 3.


(f) The third example seems to be impractical. The result of collection() will normally be a sequence of items rather than a singleton, so binding it to the context item will normally fail. With static typing it will always fail.

Michael Kay
Comment 1 Michael Kay 2009-05-18 12:30:00 UTC
In the Bucharest F2F meeting we developed a revised draft of the text of this section:

http://lists.w3.org/Archives/Member/w3c-xsl-query/2009May/0037.html

(member-only link)
Comment 2 Michael Kay 2009-05-22 21:25:55 UTC
Re-reading this text, the definition "[Definition: An Expression E *depends on* the context item if any of the following is true:"

needs to be expanded to include the following cases:

* E is "/", or any path expression beginning with "/" or "//"

The entry "E is an axis step" should be expanded to say "(including an abbreviated axis step such as '..' or '@x')"
Comment 3 Michael Kay 2010-01-12 17:43:28 UTC
The text in 
http://lists.w3.org/Archives/Member/w3c-xsl-query/2009May/0037.html has been incorporated in the 15 Dec 2009 XQuery 1.1 draft. The amendment in comment #2 was accepted in the telcon of 12 Jan 2010.