<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29246</bug_id>
          
          <creation_ts>2015-10-27 15:46:08 +0000</creation_ts>
          <short_desc>[XQ31] context item declarations</short_desc>
          <delta_ts>2015-12-15 17:35:53 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XQuery 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jmdyck</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>123964</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2015-10-27 15:46:08 +0000</bug_when>
    <thetext>Suppose a library module has a context item declaration.  Since

&quot;In a library module, a context item declaration must be external, and specifies only the static type. &quot;

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&apos;m not sure that the specification makes this explicit.

Clearly, the initial context item must be the same in all the modules.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123971</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2015-10-27 18:33:28 +0000</bug_when>
    <thetext>&gt; I presume that the context item cannot be set from the external environment,
&gt; but I&apos;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 &apos;Context Item Declaration&apos;, where we say &quot;[the initial context item] is selected as follows&quot;, we insert &quot;based on the (explicit or implicit) context item declaration in the main module&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124062</commentid>
    <comment_count>2</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2015-11-03 17:21:11 +0000</bug_when>
    <thetext>The WG agreed to fix this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124144</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2015-11-09 22:04:28 +0000</bug_when>
    <thetext>Looking at this carefully, I don&apos;t think it&apos;s actually broken.  Here is the existing text:

&lt;quote&gt;
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:
&lt;/quote&gt;

The text *initial context item* refers to this definition in the static context:

&lt;quote&gt;
[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. ]
&lt;/quote&gt;

That seems clear to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124148</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2015-11-10 09:41:38 +0000</bug_when>
    <thetext>The bug isn&apos;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).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124153</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2015-11-10 14:34:38 +0000</bug_when>
    <thetext>(In reply to Tim Mills from comment #4)
&gt; The bug isn&apos;t disputing that there is a single value for the context item,
&gt; but rather whether the value of the context item can be set by the external
&gt; environment in the case where the context item is effectively declared as
&gt; both external (in a library) and not external (in the main module).

OK, I tightened this up as follows:

&lt;quote&gt;
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.
&lt;/quote&gt;

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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124154</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2015-11-10 16:04:08 +0000</bug_when>
    <thetext>(In reply to Jonathan Robie from comment #5)
&gt; 
&gt; OK, I tightened this up as follows:

(It would have been nice to indicate what was new in your text.)

&gt; * If the declaration occurs in a main module and a value is provided for the
&gt; context item by the external environment, then the initial context item is
&gt; that value.

By adding &quot;If the declaration occurs in a main module&quot; (resp &quot;library module&quot;), you indicate that the bullets are to be applied to the context item decl in each of the query&apos;s modules. But this is odd, because the paragraph before the bullets (&quot;During query evaluation&quot;) 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.
 

&gt; If the declaration occurs in a library module, then the value of the
&gt; initial context item after processing the prolog of the main module.

This is not a sentence.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124436</commentid>
    <comment_count>7</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2015-12-15 16:10:49 +0000</bug_when>
    <thetext>&gt; &gt; If the declaration occurs in a library module, then the value of the
&gt; &gt; initial context item after processing the prolog of the main module.
&gt; 
&gt; 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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>