<?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>1998</bug_id>
          
          <creation_ts>2005-09-07 16:44:48 +0000</creation_ts>
          <short_desc>Inconsistency wrt module import new text</short_desc>
          <delta_ts>2006-02-28 16:26:03 +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>Last Call drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows 2000</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="Mary Holstege">holstege</reporter>
          <assigned_to name="Don Chamberlin">chamberl</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>5783</commentid>
    <comment_count>0</comment_count>
    <who name="Mary Holstege">holstege</who>
    <bug_when>2005-09-07 16:44:48 +0000</bug_when>
    <thetext>In the Septemnber 15th draft there is a new paragraph in section 4.11 module 
import:

A module may import its own target namespace (this is interpreted as importing 
all the other modules that share the same target namespace.)

This is too strong, and conflicts with the implementation flexibility offered
by this paragraph earlier in the same section:
The first URILiteral in a module import specifies the target namespace of the 
modules to be imported. The URILiterals that follow the at keyword are optional 
location hints, and can be interpreted or disregarded in an implementation-
defined way.

Implementations are not required to import all modules for a namespace for 
different namespaces; they should not be so required just because the namespace
happens to be the same.  

Proposal: strike &quot;all the&quot; and continue the parenthetical sentence &quot;or by 
interpreting the location hints in an implementation-defined way&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5878</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2005-09-08 01:33:54 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt;
&gt; Implementations are not required to import all modules for a namespace

I think they are. I don&apos;t know about the Sept 15th draft, but the April 4th
draft says (in the para before the one you quoted): &quot;Each module import names a
target namespace and imports all the modules that share this target namespace.&quot; </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5888</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2005-09-08 12:56:37 +0000</bug_when>
    <thetext>I agree (with Michael Dyck) - the spec says that when you import a namespace,
you import all modules for that namespace, and this applies whether it&apos;s your
own namespace or not. Of course, you can only import those modules that you know
about, but my interpretation is that this includes any modules reached
transitively. For example if A imports N at N1, and N1 imports N at N2, then I
think A has access to the variables and functions declared in N2, regardless
whether N is the namespace of A or not.

Michael Kay</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5891</commentid>
    <comment_count>3</comment_count>
    <who name="Mary Holstege">holstege</who>
    <bug_when>2005-09-08 15:23:27 +0000</bug_when>
    <thetext>Yes, I now see this constraint added to modules in general and it appears to
have snuck in in some earlier draft, where I missed it. Apologies for not
having noticed this until now.

I would, nevertheless, very much appreciate knowing when this new rule was 
agreed to. The last I remember significant discussions of module import 
semantics was at the August 2004 F2F (the whole module resources vs module 
renaming discussion). At that time, there was no such rule in the spec, and I 
see no such rule in the proposal we agreed to at that time.  Indeed, I recall as 
part of the discussion (although this point doesn&apos;t seem to be captured in the 
official minutes) a rejection of this interpretation.

This &quot;all modules with that namespace&quot; is a weird and unenforceable constraint
anyway and should be dropped, especially if we never explicitly agreed to it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>5892</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2005-09-08 16:02:28 +0000</bug_when>
    <thetext>I don&apos;t know the history of this, I&apos;m afraid.

The current rule for module import does have the advantage that it&apos;s reasonably
analogous to the rules in XML Schema, where import is primarily about allowing
reference to components in another namespace, rather than about locating the
documents defining those components. (But I confess that XML Schema is far from
being a wonderful role model in this area...).

I think modules in their current state just about hang together. It&apos;s not a
wonderful design but it more-or-less works. I don&apos;t think minor tweaks are going
to improve it much. </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6150</commentid>
    <comment_count>5</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2005-09-14 17:52:25 +0000</bug_when>
    <thetext>I propose to resolve this issue by making the following changes:

(1) In section 4.11, Module Import, change the second sentence of the first 
paragraph to the following: &quot;Each module import names a target namespace and 
imports an implementation-defined set of modules that have this target 
namespace.&quot; 

(2)In section 4.11, fifth paragraph, change the first sentence to the 
following: &quot;A module may import its own target namespace (this is interpreted 
as importing an implementation-defined set of other modules that share its
target namespace.)&quot; 

(3) Add the following item to the list of implementation-defined items in 
Appendix D: &quot;The process by which the specific modules to be imported by a 
Module Import are identified.&quot;

Regards,
Don Chamberlin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6528</commentid>
    <comment_count>6</comment_count>
    <who name="Don Chamberlin">chamberl</who>
    <bug_when>2005-09-28 13:50:39 +0000</bug_when>
    <thetext>Mary,
On Sept. 28, 2005, the Query Working Group decided to adopt the text specified 
above (in Additional Comment #5). We believe that this action resolves the 
issue and addresses your concerns. I have marked this issue as &quot;Fixed&quot;. If you 
are satisfied with the resolution, please respond by marking the issue 
as &quot;Closed&quot;.
Regards,
Don Chamberlin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6616</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2005-09-30 03:04:27 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt;
&gt; &quot;Each module import names a target namespace and imports an
&gt; implementation-defined set of modules that have this target namespace.&quot;

So if there are two or more modules co-operatively implementing a given target
namespace, you can&apos;t portably know that they&apos;ll all be imported, so the only
portable course of action is to never have more than one module for a given
target namespace. Which raises the question, why does XQuery allow multi-module
imports anyway? It seems to be a nasty complication with dubious benefit.
Perhaps it should be deferred. Per Bothner suggested this 18 months ago and
didn&apos;t get a good answer, in my opinion.
http://lists.w3.org/Archives/Public/public-qt-comments/2004Mar/0013.html

(I can see why you might want multiple *alternative* modules for a namespace,
i.e., each one completely implementing a given interface, but that&apos;s a different
matter. For that, you&apos;d want assurance from the spec that exactly *one* of those
modules would be imported.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6622</commentid>
    <comment_count>8</comment_count>
    <who name="Mary Holstege">holstege</who>
    <bug_when>2005-09-30 15:19:05 +0000</bug_when>
    <thetext>I&apos;m satisfied with this resolution, although perhaps Michael Dyck is suggesting
we reopen it (although it looks like a distinct issue to me).

In answer to the question he poses (why allow more than one module per ns?)
the short answer is because function namespaces and physical partitioning
have nothing to do with one another. If your only choice is between putting all
20000 lines of XQuery into a single file or inventing random distinct namespaces
just so you can partition the physical file (which will drive all the clients
of that module completely spare trying to remember which function is in which
namespace), you have no sane solution to a basic development issue.

The current design also has the salutary effect of allowing one to hide all 
the &quot;internal functions&quot; in one physical file, have a &quot;api library&quot; import that
set, and only advertise the api library to the world. Thus: function export, 
without any special mechanism for function export.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>6632</commentid>
    <comment_count>9</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2005-10-01 23:49:30 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt;
&gt; In answer to the question he poses (why allow more than one module per ns?)
&gt; the short answer is because function namespaces and physical partitioning
&gt; have nothing to do with one another.

(If that were true, then in addition to multiple modules implementing a single
namespace, you could also have a single module implementing multiple namespaces.
But that&apos;s beside the point, I think.)

&gt; If your only choice is between putting all
&gt; 20000 lines of XQuery into a single file or inventing random distinct namespaces
&gt; just so you can partition the physical file (which will drive all the clients
&gt; of that module completely spare trying to remember which function is in which
&gt; namespace), you have no sane solution to a basic development issue.

Right, and if the Comment #5 wording is adopted, and you want portable code,
that choice *is* your only choice, so you have no sane solution to the issue.

&gt; The current design also has the salutary effect of allowing one to hide all 
&gt; the &quot;internal functions&quot; in one physical file, have a &quot;api library&quot; import that
&gt; set, and only advertise the api library to the world. Thus: function export, 
&gt; without any special mechanism for function export.

If the api module and the internal module have the same target namespace, then
importing that namespace isn&apos;t guaranteed to import the api module only:

-- it might (and under the prior semantics, it would) import both modules, in
which case the internal functions wouldn&apos;t be hidden; or

-- it might import only the internal module, in which case the client code
(using only the functions defined in the api module) would break.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>8277</commentid>
    <comment_count>10</comment_count>
    <who name="Michael Dyck">jmdyck</who>
    <bug_when>2006-02-16 03:26:39 +0000</bug_when>
    <thetext>Could I have a response to my previous comment on this issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>8487</commentid>
    <comment_count>11</comment_count>
    <who name="Mary Holstege">holstege</who>
    <bug_when>2006-02-28 16:26:03 +0000</bug_when>
    <thetext>
The WG considers this issue closed and intends to make no change in this
area.  If you not satisfied with this resolution, please let us know.

In answer to your question: The fact is that there is much that is 
implementation defined in this area, starting with the basic point that
the entire module feature is optional. Further, URI resolution is implementation
defined as well.  So, even if the spec were to insist that location URIs
were more than hints and they must be obeyed, there is no guarantee that
the URI resolver in two implementations would work as expected.  

It it not reasonable to expect to be able to pick up a large application (i.e. 
one dependent on modules) from one implementation and drop it down on another
and expect it to work with no knowledge of the implementation. This goes far 
beyond modules:
There are plenty of other implementation-dependent/defined features in the
XQuery language that can dramatically affect how or whether applications
will work, e.g. static typing, URI resolution wrt fn:doc, locating schemas and
whether to apply them at all.

I don&apos;t believe, for modules, this is different in kind from what you find in 
other programming languages, although it certainly differs in degree.
The C _language spec_ does not tell you what you get when you put 
#include &quot;foo.h&quot; into your program or where it will be located: your compiler 
documentation does. 

Speaking only for myself, I would have preferred a design that made locations
more than just hints, but given the range of contexts in which XQuery 
implementations are living -- as self-embedded application languages
working off file systems or off their own internal stores, as queries embedded
in the context of SQL engines, as transformation engines inside application
servers, and others besides -- it is difficult to come up with hard and
fast rules that won&apos;t make certain reasonable implementation choices impossible.
The price application developers have to pay for this is the possibility of
having to modify applications to work in certain implementation contexts.
The current design has the virtue of making reasonable implementations possible.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>