Here is definition of module:<br>&quot;A query can be assembled from one or more fragments called
<b>modules</b>. [<a title="module" id="dt-module" name="dt-module">Definition</a>: A <b>module</b> is a fragment of XQuery
code that conforms to the <a href="http://www.w3.org/TR/xquery/#doc-xquery-Module">Module</a>
grammar and can independently undergo 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>. Each module is either a <a title="main module" href="http://www.w3.org/TR/xquery/#dt-main-module">main module</a> or a <a title="library module" href="http://www.w3.org/TR/xquery/#dt-library-module">
library module</a>.]&quot;<br><br>Since modules could independetly undergo the static analysis phase, then <br>I understand wherever it&#39;s imported, it&#39;s in-scope schema type definition should not be <br>redefined by importing module.
<br><div><span class="gmail_quote"><br></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><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>
</blockquote></div><br>