<?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>5722</bug_id>
          
          <creation_ts>2008-05-29 09:39:44 +0000</creation_ts>
          <short_desc>[XQuery] Importing the same module from different modules.</short_desc>
          <delta_ts>2009-02-24 17:05:06 +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 1.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>REMIND</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="Oliver Hallam">oliver</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>jim.melton</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>20303</commentid>
    <comment_count>0</comment_count>
    <who name="Oliver Hallam">oliver</who>
    <bug_when>2008-05-29 09:39:44 +0000</bug_when>
    <thetext>Assume a module M declaring a variable $v as &lt;a/&gt;.  Then assume modules A and B both importing M, and exposing functions f() returning $v.  Finally assume a query importing modules A and B.  Should &quot;A:f() is B:f()&quot; evaluate to true?

As far as I can tell this is implementation defined, since the import statement itself imports an implementation-defined set of modules (and so it is implementation defined whether it imports the same module as before, or a copy).
On the other hand the specification states that &quot;Each module has its own static context&quot;, but this still doesn&apos;t say whether the two imports should be considered as the same module.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20306</commentid>
    <comment_count>1</comment_count>
    <who name="Oliver Hallam">oliver</who>
    <bug_when>2008-05-29 13:23:48 +0000</bug_when>
    <thetext>Consider now a module M&apos; with the same namespace as M that also declares a variable $v. (but neither M nor M&apos; import their own namespace)

Now assume A imports M (referring to it specifically via a location hint) and B imports M&apos;.

The behaviour of a query importing A and B is implementation defined.

I can see several different things to do here:

1) Import both M and M&apos; in both A and B.  In this case an error is reported because the same variable is declared in both M and M&apos;.  However the drawback with this approach is that a library can be written using variables and functions in one module, whilst importing a different module in the same namespace.  When it is imported by a different query it may cease to function.

2) Import M and M&apos; as different libraries (albeit with the same namespace) into A and B respectively.  This does allow there to be two global variables with the same name and namespace, although at no point are both in scope.

3) Ignore one of the location hints.  This could lead to unexpected and arbitrary behavior.

4) Treat M and M&apos; as different libraries (that is do not allow A to have access to M&apos;, and vice versa), but raise an error if there are any variable/function collisions (but do allow both M and M&apos; to both import another module in the same namespace)

What are other implementations doing in this case?

The specification could go further by specifying the following:
1) Whether the &quot;implementation-defined set of modules that share this target namespace&quot; is always the same set of modules for the same namespace (excluding the module doing the importing).
2) If this is not true, then whether the union of all these sets of modules can contain two variables/functions with the same name.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>20369</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2008-06-03 19:28:45 +0000</bug_when>
    <thetext>[personal response:]
I don&apos;t think the spec supports the notion of &quot;importing a *copy* of a module&quot;. So, in the first scenario, where there&apos;s only one module implementing the imported namespace, A and B do import the same module, and &quot;A:f() is B:f()&quot; evaluates to true.

In the second scenario, if the user attempts to have A import M and B import M&apos;, then I believe each of (1), (2), and (4) is a justifiable outcome. Re (3), the implementation is certainly free to ignore location hints, but it&apos;s still obliged to define which set of modules is imported in each case, which would then result in an outcome such as (1), (2), or (4) (or others).

I think (2) vs (4) hinges on an ambiguity in the spec. For example, 4.11 says:
    It is a static error if the expanded QName of a
    variable declared in an imported module is equal
    ... to the expanded QName of a variable declared 
    in the importing module or in another imported module ...
Where it says &quot;another import module&quot;, does it mean
    another module imported by the importing module
or
    another module imported anywhere in the universe of the query
? The former interpretation allows outcome (2) but not (4); the latter allows (4) but not (2).

Anyhow, I agree that the spec is fairly vague on the matter.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>23906</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2009-02-24 17:05:06 +0000</bug_when>
    <thetext>We agreed to adopt http://lists.w3.org/Archives/Member/w3c-xml-query-wg/2009Feb/0041.html as a normative appendix.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>