This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Suppose a library module has a context item declaration. Since "In a library module, a context item declaration must be external, and specifies only the static type. " the context item effectively declared as external. Suppose that the main module imports this library and has its own context item declaration declare context item := 1; I presume that the context item cannot be set from the external environment, but I'm not sure that the specification makes this explicit. Clearly, the initial context item must be the same in all the modules.
> I presume that the context item cannot be set from the external environment, > but I'm not sure that the specification makes this explicit. Not quite explicit, I think. To make it so, I suggest that in the section for 'Context Item Declaration', where we say "[the initial context item] is selected as follows", we insert "based on the (explicit or implicit) context item declaration in the main module".
The WG agreed to fix this.
Looking at this carefully, I don't think it's actually broken. Here is the existing text: <quote> During query evaluation, a singleton focus is created in the dynamic context for the evaluation of the QueryBody in the main module, and for the initializing expression of every variable declaration in every module. The context item of this singleton focus is called the *initial context item*, and is selected as follows: </quote> The text *initial context item* refers to this definition in the static context: <quote> [Definition: In the dynamic context of every module in a query, the context item component must have the same setting. If this shared setting is not absentDM31, it is referred to as the initial context item. ] </quote> That seems clear to me.
The bug isn't disputing that there is a single value for the context item, but rather whether the value of the context item can be set by the external environment in the case where the context item is effectively declared as both external (in a library) and not external (in the main module).
(In reply to Tim Mills from comment #4) > The bug isn't disputing that there is a single value for the context item, > but rather whether the value of the context item can be set by the external > environment in the case where the context item is effectively declared as > both external (in a library) and not external (in the main module). OK, I tightened this up as follows: <quote> If external is specified, then: * If the declaration occurs in a main module and a value is provided for the context item by the external environment, then the initial context item is that value. If the declaration occurs in a library module, then the value of the initial context item after processing the prolog of the main module. The means by which an external value is provided by the external environment is implementation-defined. * If no value is provided for the context item by the external environment, and VarDefaultValue is specified, then the initial context item is the result of evaluating VarDefaultValue as described below. </quote> The text in this section is rather unorganized, and could certainly be tightened up. We could do that during the 2nd CR phase since this is editorial, I prefer not to destabilize this part of the spec before then.
(In reply to Jonathan Robie from comment #5) > > OK, I tightened this up as follows: (It would have been nice to indicate what was new in your text.) > * If the declaration occurs in a main module and a value is provided for the > context item by the external environment, then the initial context item is > that value. By adding "If the declaration occurs in a main module" (resp "library module"), you indicate that the bullets are to be applied to the context item decl in each of the query's modules. But this is odd, because the paragraph before the bullets ("During query evaluation") is talking about something that happens once per query eval. Therefore, I prefer my suggestion (in comment 1), which clarifies that the bullets only apply to the context item decl in the main module. > If the declaration occurs in a library module, then the value of the > initial context item after processing the prolog of the main module. This is not a sentence.
> > If the declaration occurs in a library module, then the value of the > > initial context item after processing the prolog of the main module. > > This is not a sentence. I changed this to: Note: If the declaration occurs in a library module, then it does not set the value of the initial context item, it uses the value set by the main module.