Thank you Michael, seems we are now getting closer about this issue.<br>We all agree that modules in XQuery could be compiled independently.<br>(Original definition:<a title="module" id="dt-module" name="dt-module"></a>A <b>
module</b> is a fragment of XQuery
code <br>that conforms to the <a href="http://www.w3.org/TR/xquery/#doc-xquery-Module">Module</a>
grammar and can independently undergo <br>the <a title="static analysis phase" href="http://www.w3.org/TR/xquery/#dt-static-analysis">static analysis
phase</a> described in <a href="http://www.w3.org/TR/xquery/#id-expression-processing"><b>2.2.3
Expression Processing</b></a>. )<br><br>Then to what extent this definition &quot;can independently undergo <br>
the <a title="static analysis phase" href="http://www.w3.org/TR/xquery/#dt-static-analysis">static analysis
phase</a> &quot; should be followed?<br><br>Is it an optional feature of module, or a strict rule for any XQuery implementation?<br>This two choices will lead to two design---although for &quot;normal&quot; case the two<br>
designs will show no difference, but still the two designs are different in essence, and will<br>show different behavior under some special case such as &quot;redefine&quot;.<br><br>For example, if we consider it&#39;s a strict rule, then any design
<br>that could not be implemented in independent module compilation<br>should be considered as not conformant to spec.<br>Otherwise, we have to consider that, &quot;can independently undergo <br>

the <a title="static analysis phase" href="http://www.w3.org/TR/xquery/#dt-static-analysis">static analysis
phase</a> &quot; is an optional feature of XQuery&#39;s module.<br><br>Harrison<br><br><div><span class="gmail_quote">2008/1/11, Michael Kay &lt;<a href="mailto:mike@saxonica.com">mike@saxonica.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">You are quite correct that the XQuery specification says 
nothing about how xs:redefine is handled. This was a deliberate choice, the WG 
discussed the matter and decided that nothing useful could be said. This is 
because the specification quite deliberately doesn&#39;t say, in the case of &quot;import 
schema&quot;, where the schema components are obtained from, and this means that if 
(as in this case) there are different versions of the schema components 
available then it&#39;s not defined (by the specification) which version is 
loaded.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">I think there are two possibilities:</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">(a) both modules use the same schema components for 
namespace <u><a href="http://www.w3.org/XQueryTest/simple" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/XQueryTest/simple</a></u>, which must be the 
post-redefine components. In this case the answer is true.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">(b) the two modules use different schema components for 
namespace <a href="http://www.w3.org/XQueryTest/simple" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/XQueryTest/simple</a>&nbsp; 
-&nbsp; one gets the pre-redefine components, the other gets the post-redefine 
version. This violates the consistency requirements documented in the 
specification; the specification says that in this situation the results are 
completely undefined. Clearly a good processor will detect the inconsistency and 
refuse to run the query, but the spec makes it clear that anything might happen 
- it&#39;s like submitting a random binary file to the Java VM.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">If you&#39;re a user, the clear implication is: don&#39;t do 
this.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">If you&#39;re an implementor, the implication is: either ensure 
that both modules use the post-redefine version of the type (which probably 
isn&#39;t feasible if the modules are compiled separately).&nbsp;Alternatively, 
detect and report the inconsistency if you can, but your product is not 
nonconformant if you don&#39;t.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Incidentally, it&#39;s no different from having the two modules 
import the schema from different locations and picking up different versions; it 
doesn&#39;t require xs:redefine to trigger this problem.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">You&#39;re right that XSLT handles the issue quite differently. 
XSLT builds a single schema that serves all modules, both statically and 
dynamically. This has the disadvantage that it makes independent compilation of 
modules extremely difficult. But then, it&#39;s almost impossible to compile modules 
independently in XSLT anyway.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"></font></span>&nbsp;</div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2">Michael Kay</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial" size="2"><a href="http://www.saxonica.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.saxonica.com/</a></font></span>
</div><br>
<blockquote dir="ltr" style="border-left: 2px solid rgb(0, 0, 255); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
  <div dir="ltr" align="left" lang="en-us">
  <hr>
  <font face="Tahoma" size="2"><b>From:</b> <a href="mailto:talk-bounces@x-query.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">talk-bounces@x-query.com</a> 
  [mailto:<a href="mailto:talk-bounces@x-query.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">talk-bounces@x-query.com</a>] <b>On Behalf Of </b>he 
  harrison<br><b>Sent:</b> 09 January 2008 02:48<br><b>To:</b> 
  <a href="mailto:talk@x-query.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">talk@x-query.com</a><br><b>Subject:</b> [xquery-talk] about &quot;module&quot; in XQuery 
  spec<br></font><br></div><div><span class="q" id="q_11764871fa84ca57_1">
  <div></div>
  <div><font style="color: rgb(0, 0, 0);" size="-1">Hi,<br>I come up with a problem 
  when reading XQuery1.0 spec., following is my case:<br><br>a.xq:<br><br>module 
  namespace ma=&quot; <a href="http://www.w3.org/TestModules/moduleA" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/TestModules/moduleA</a>&quot;;<br>import schema 
  namespace simple=&quot;<a href="http://www.w3.org/XQueryTest/simple" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)"> 
  http://www.w3.org/XQueryTest/simple</a> &quot; at &quot;schema_a.xsd&quot;;<br>declare 
  function ma:funcA()<br>{<br>&nbsp;&nbsp; &quot;40&quot; cast as 
  simple:myType<br>};<br><br>b.xq:<br><br>declare namespace mb=&quot; <a href="http://www.w3.org/TestModules/moduleB" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/TestModules/moduleB 
</a>&quot;;<br>import module 
  namespace ma=&quot;<a href="http://www.w3.org/TestModules/moduleA" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/TestModules/moduleA</a>&quot; at &quot; a.xq&quot;;<br>import 
  schema namespace simple=&quot; <a href="http://www.w3.org/XQueryTest/simple" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/XQueryTest/simple</a>&quot; at 
  &quot;schema_b.xsd&quot;;<br><br>declare function mB:funcB()<br>{<br>&nbsp; ma:funcA() 
  instance of 
  simple:myType<br>};<br><br>&lt;result&gt;{mb:funcB()}&lt;/result&gt;<br><br>schema_a.xsd: 
  <br><br>&lt;xs:schema xmlns:xs=&quot;<a href="http://www.w3.org/2001/XMLSchema" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/2001/XMLSchema</a>&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  xmlns:simple=&quot; <a href="http://www.w3.org/XQueryTest/simple" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/XQueryTest/simple 
  </a>&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  targetNamespace=&quot;<a href="http://www.w3.org/XQueryTest/simple" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/XQueryTest/simple</a>&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  elementFormDefault=&quot;qualified&quot; attributeFormDefault=&quot;qualified&quot; 
  <br>&gt;<br>&nbsp; &lt;xs:simpleType name = 
  &quot;myType&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:restriction base = 
  &quot;xs:int&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:minInclusive value = 
  &quot;1&quot;/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:maxInclusive value = 
  &quot;50&quot;/&gt; <br>&nbsp;&nbsp;&nbsp; &lt;/xs:restriction&gt;<br>&nbsp;&nbsp; 
  &lt;/xs:simpleType&gt;&nbsp;&nbsp; 
  <br>&lt;/xs:schema&gt;<br><br>schema_b.xsd:<br><br>&lt;xs:schema xmlns:xs=&quot; <a href="http://www.w3.org/2001/XMLSchema" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/2001/XMLSchema
</a> 
  &quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  xmlns:simple=&quot;<a href="http://www.w3.org/XQueryTest/simple" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/XQueryTest/simple</a>&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  targetNamespace=&quot; <a href="http://www.w3.org/XQueryTest/simple" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.w3.org/XQueryTest/simple 
  </a>&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  elementFormDefault=&quot;qualified&quot; 
  attributeFormDefault=&quot;qualified&quot;<br>&gt;<br>&nbsp; 
  &lt;redefine<br>&nbsp;&nbsp;&nbsp; 
  schemaLocation=&quot;schema_a.xsd&quot;&gt;<br>&nbsp;&nbsp;&nbsp; &lt;extension 
  base=&quot;simple:myType&quot;&gt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;xs:minInclusive value = 
  &quot;51&quot;/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:maxInclusive 
  value = &quot;100&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/extension&gt;<br>&nbsp; 
  &lt;/redefine&gt;<br>&lt;/xs:schema&gt;<br><br>What would be the result of 
  this case? <br>true? false? runtime error? or implementation define?<br>Or in 
  another word, would the type in module a.xq should<br>be redefined by module 
  c.xq&#39;s imported schema definition?<br><br>This case is related with how to 
  understand the XQuery&#39;s &quot;module&quot;. <br><br>Let me give my 
  understanding:<br></font>XSLT&#39;s module, in my understanding, should be 
  &quot;included&quot; in <br>another module to compile, could not be compiled 
  independently,<br>in other words, it&#39;s a &quot;white box&quot;, its semantic <br>depends 
  on where it&#39;s included or imported(because its schema type could be 
  <br>differently redefined in different including or importing 
  module).<br>&nbsp;<br>While I think XQuery&#39;s module is different with XSLT&#39;s 
  module, I think XQuery spec. <br>allow its module be compiled independently, 
  no matter where the module is imported,<br>module&#39;s semantic should not be 
  changed, in other words, XQuery&#39;s module<br>is a &quot;black box&quot;, wherever module 
  is imported, module&#39;s schema type definition should not be <br>affected by 
  type redefine mechanism.<br><br>The reason why I make such conclusion is from 
  following XQuery spec statement:<br>1 &quot;A <a title="module import" href="http://www.w3.org/TR/xquery/#dt-module-import" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">module 
  import</a> imports only functions and variable declarations; it does not 
  import other objects from the imported modules, such as <a title="in-scope schema definitions" href="http://www.w3.org/TR/xquery/#dt-issd" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">in-scope schema 
  definitions</a> or <a title="statically known namespaces" href="http://www.w3.org/TR/xquery/#dt-static-namespaces" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">statically known namespaces</a>. 
<span style="color: rgb(255, 0, 0);">Module imports are not transitive</span>¡ªthat is, 
  importing a module provides access only to function and variable declarations 
  contained directly in the imported module.&quot; <br><br>Here XQuery&#39;s statement is 
  clearly different with XSLT&#39;s statement about module import. <br>In XSLT spec, 
  module imports are transitive while XQuery clearly stated that they <br>are 
  not, so XQuery&#39;s module import must be something different with XSLT&#39;s module 
  import.<br>My thought is, XQuery&#39;s module is a &quot;black box&quot; while XSLT&#39;s module 
  is a &quot;white box&quot;<br><br>2 &quot;It is a <a title="static error" href="http://www.w3.org/TR/xquery/#dt-static-error" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">static 
  error</a> [<a title="err:XQST0036" href="http://www.w3.org/TR/xquery/#ERRXQST0036" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">err:XQST0036</a>] to import a module if the importing module&#39;s 
  <a title="in-scope schema type" href="http://www.w3.org/TR/xquery/#dt-is-types" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">in-scope schema 
  types</a> do not include definitions for the schema type names that appear in 
  the declarations of variables and functions (whether in an argument type or 
  return type) that are present in the imported module and are referenced in the 
  importing module.&quot;<br><br>Here spec. force user to import interface needed 
  schema types, if we consider XQuery&#39;s<br>module as &quot;white box&quot;, then all 
  imported types in &quot;white box&quot; has already imported, then <br>this statement 
  seems <span style="margin-right: 15px;"></span>lead to redundancy, however if 
  we consider XQuery&#39;s module<br>as a &quot;black box&quot;, then this statement is quite 
  nature to understand. <br><br>Could someone offer me some comment? <br>Many 
  thanks! <br><span><span><br></span></span></div></span></div></blockquote></div>
</blockquote></div><br>