<?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>19267</bug_id>
          
          <creation_ts>2012-10-03 22:57:40 +0000</creation_ts>
          <short_desc>[XQ3.0] Context item declared in multiple modules</short_desc>
          <delta_ts>2013-06-19 09:34:47 +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.0</component>
          <version>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</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="Michael Kay">mike</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          
          
          <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>75268</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-10-03 22:57:40 +0000</bug_when>
    <thetext>It is permitted for context item declarations to appear in more than one module.

The declaration in a library module is not allowed to set an initial value for the context item. A declaration that does not set an initial value must, by the nature of the syntax, specify &quot;external&quot;.

The semantics of &quot;external&quot; require the value to be supplied &quot;by the external environment&quot;. However, the main module might contain an initializer for the context item, in which case it makes sense to use the value from that initializer, rather than reporting an error because the value was not supplied externally.

(Perhaps it was intended that the &quot;external environment&quot; of a library module includes the main module - if so, it should say so.)

The simplest fix is to change the semantics of &quot;external&quot; to permit the value to be supplied as a result of evaluating the initializer contained in the main module. A bolder fix would be to change the grammar so that in a library module, neither &quot;external&quot; nor an initial value may be specified (only a type, which is why the declaration exists in a library module).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75306</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2012-10-04 14:55:52 +0000</bug_when>
    <thetext>A follow-up question.

Suppose a library module has

declare context item external;

and the main module has

declare context item := 23;

Now if no external context item is supplied, it is clear that the context item in both modules should take the value 23. But what if an external context item is supplied, say 87? The rules for &quot;declare context item external&quot; suggest that the value should be 87, but the rules for &quot;declare context item := 23&quot; suggest it should be 23. But it must (I hope) be the same everywhere. Logic dictates, I think, that the value 23 wins; this reflects the interpretation that when we say the value is &quot;supplied by the external environment&quot; we include the case where it is supplied by the main module.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75701</commentid>
    <comment_count>2</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-10-09 16:09:23 +0000</bug_when>
    <thetext>In today&apos;s telcon, we decided that library modules use the value of the context item, as determined by the main module (which provides either a value or an external declaration).

Getting the wording right is going to take thought, especially in C.2 Module Dynamic Context.

One possible approach:

context item: Can be overwritten or augmented by prolog?
=&gt; overwritten by a 4.17 Context Item Declaration in the main module</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77414</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-10-30 13:31:27 +0000</bug_when>
    <thetext>Define term &quot;initial context item&quot;, which is used as the initial
context item for evaluating the prolog and the main body of query, and
is the same for all modules in a query. 


Dynamic Context properties for &quot;context item&quot;:

* Default initial value 	

In a main module, none. In a library module, the context item of the main module.

* Can be overwritten or augmented by implementation? 	

overwriteable.

* Can be overwritten or augmented by prolog? 	

overwritten with a context item declaration. 	

* Can be overwritten or augmented by expressions? 	

overwritten during evaluation of path expressions and predicates.

* Consistency rules

The main module and all library modules must all have the same context item.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77415</commentid>
    <comment_count>4</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-10-30 13:44:21 +0000</bug_when>
    <thetext>Context item declarations will also be modified as follows:

In a library module, a context item declaration &lt;add&gt;must be external&lt;/add&gt;, and specifies only the static type&lt;add&gt;; the context item is the context item of the main module.&lt;/add&gt; Specifying a VarValue or VarDefaultValue for a context item declaration in a library module is a static error [err:XQST0113].</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77417</commentid>
    <comment_count>5</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-10-30 13:50:29 +0000</bug_when>
    <thetext>(In reply to comment #3)
 
&gt; * Can be overwritten or augmented by prolog? 	
&gt; 
&gt; overwritten with a context item declaration. 	

&lt;add&gt;in the main module&lt;/add&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77418</commentid>
    <comment_count>6</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-10-30 13:52:27 +0000</bug_when>
    <thetext>The Working Group has adopted the resolution in comment #3, #4, and #5, modifying the consistency constraints to be less declarative (eliminate &quot;must&quot;).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79781</commentid>
    <comment_count>7</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2012-12-09 23:03:34 +0000</bug_when>
    <thetext>When implementing this, I added the initial context item as a separate item in appendix C2.

* Component 	
Initial context item 
* Default initial value 	
none
* Can be overwritten or augmented by implementation? 	
overwriteable
* Can be overwritten or augmented by prolog? 	
overwritten by a 4.17 Context Item Declaration in the main module.
* Can be overwritten or augmented by expressions? 	
no
* Consistency rules
query body and prologs of all modules have the same initial context item

* Component 	
Context item 
* Default initial value 
the initial context item 	
* Can be overwritten or augmented by implementation? 	
no
* Can be overwritten or augmented by prolog? 
only via the initial context item	
* Can be overwritten or augmented by expressions? 
overwritten during evaluation of path expressions and predicates 	
* Consistency rules
none</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>