[Bug 6272] New: Context item declaration

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

           Summary: Context item declaration
           Product: XPath / XQuery / XSLT
           Version: Working drafts
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XQuery 1.1
        AssignedTo: jonathan.robie@redhat.com
        ReportedBy: mike@saxonica.com
         QAContact: public-qt-comments@w3.org


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


-- 
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 Thursday, 4 December 2008 14:54:53 UTC