[Bug 5224] [XQuery] Dynamic context in global variable initializers

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





------- Comment #5 from jmdyck@ibiblio.org  2008-01-16 05:40 -------
(In reply to comment #4)
> My initial comment was: "There seems to be no statement in XQuery that says
> whether the context item, position, and size are defined when referenced
> within the initializing expression of a global variable."
> 
> It seems that the WG has decided that these are defined,

Not necessarily. If the implementation leaves them undefined in the initial
dynamic context, and nothing else in the prolog causes them to be defined in
the dynamic context that's in effect at the point the reference is made, then
they would be undefined.

> and that they are the same as the context item, position, and size in
> the expression that forms the QueryBody in the main module.

Not necessarily that either, since a library module might get an initial
dynamic context that differs from that of the main module. (E.g., I can imagine
an implementation saying that the initial focus is undefined for a library
module, but set via invocation parameters for the main module.)

It *is* normally true, I think, that the focus for the QueryBody in the main
module is the same as the focus for initializing expressions in the main
module, which is also the same as the focus in the initial dynamic context for
the main module. However,

(a) the focus for an initializing expression isn't always the same as the focus
for expressions *within* the initializing expression; and

(b) an implementation is allowed (as far as I can tell) to define an option
declaration that sets the focus, in which case the initial focus, the focus at
an initializing expression, and the focus at the QueryBody might all be
different.


> "... Variable Values and Function Implementations are populated only for those
> variables and functions that are within the static context of the expression".

Note that the definition of the 'variable values' dynamic component already
states that (for a given expression) it contains the same set of variables as
the 'in-scope variables' static component. The 'function implementations'
dynamic component doesn't quite make the corresponding statement with respect
to the 'function signatures' static component; perhaps it should. Anyway,
appendix C.2 requires static/dynamic consistency for both variables and
functions.

Received on Wednesday, 16 January 2008 05:40:26 UTC