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 29246 - [XQ31] context item declarations
Summary: [XQ31] context item declarations
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.1 (show other bugs)
Version: Candidate Recommendation
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: 2015-10-27 15:46 UTC by Tim Mills
Modified: 2015-12-15 17:35 UTC (History)
1 user (show)

See Also:


Attachments

Description Tim Mills 2015-10-27 15:46:08 UTC
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.
Comment 1 Michael Dyck 2015-10-27 18:33:28 UTC
> 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".
Comment 2 Jonathan Robie 2015-11-03 17:21:11 UTC
The WG agreed to fix this.
Comment 3 Jonathan Robie 2015-11-09 22:04:28 UTC
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.
Comment 4 Tim Mills 2015-11-10 09:41:38 UTC
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).
Comment 5 Jonathan Robie 2015-11-10 14:34:38 UTC
(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.
Comment 6 Michael Dyck 2015-11-10 16:04:08 UTC
(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.
Comment 7 Jonathan Robie 2015-12-15 16:10:49 UTC
> > 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.