<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16587" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=453122620-11012008><FONT face=Arial
color=#0000ff size=2>I don't think a product has to provide independent
compilation to be conformant (clearly).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=453122620-11012008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=453122620-11012008><FONT face=Arial
color=#0000ff size=2>The specification says that there are consistency
requirements such that the schemas imported by different modules must be
consistent with each other in various ways. Doing such a consistency check can
be done when you "link" the modules together. In the old days "linking" was
identified as a separate step that happened between the compile and run steps;
these days it is usually done as part of loading and running. I think there's
definitely an implication that some consistency checking across modules should
be done at linking time, whenever this might be.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=453122620-11012008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=453122620-11012008><FONT face=Arial
color=#0000ff size=2>Michael Kay</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=453122620-11012008><FONT face=Arial
color=#0000ff size=2>http://www.saxonica.com/</FONT></SPAN></DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> he harrison
[mailto:harrison076@gmail.com] <BR><B>Sent:</B> 11 January 2008
03:01<BR><B>To:</B> Michael Kay<BR><B>Cc:</B>
talk@x-query.com<BR><B>Subject:</B> Re: [xquery-talk] about "module" in XQuery
spec<BR></FONT><BR></DIV>
<DIV></DIV>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 id=dt-module title=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
"can independently undergo <BR>the <A title="static analysis phase"
href="http://www.w3.org/TR/xquery/#dt-static-analysis">static analysis
phase</A> " 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 "normal" 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
"redefine".<BR><BR>For example, if we consider it'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, "can independently undergo <BR>the <A
title="static analysis phase"
href="http://www.w3.org/TR/xquery/#dt-static-analysis">static analysis
phase</A> " is an optional feature of XQuery's module.<BR><BR>Harrison<BR><BR>
<DIV><SPAN class=gmail_quote>2008/1/11, Michael Kay <<A
href="mailto:mike@saxonica.com">mike@saxonica.com</A>>:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff 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't say, in the case of "import
schema", 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's not defined (by the specification) which version is
loaded.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>I think
there are two possibilities:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>(a) both
modules use the same schema components for namespace <U><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/XQueryTest/simple"
target=_blank>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 face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>(b) the
two modules use different schema components for namespace <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/XQueryTest/simple"
target=_blank>http://www.w3.org/XQueryTest/simple</A> - 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's like submitting a random binary file to the Java
VM.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>If
you're a user, the clear implication is: don't do this.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>If
you're an implementor, the implication is: either ensure that both modules
use the post-redefine version of the type (which probably isn't feasible if
the modules are compiled separately). Alternatively, detect and report
the inconsistency if you can, but your product is not nonconformant if you
don't.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Incidentally, it's no different from having the two modules import
the schema from different locations and picking up different versions; it
doesn't require xs:redefine to trigger this problem.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>You'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's almost impossible to compile modules independently
in XSLT anyway.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Michael
Kay</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.saxonica.com/"
target=_blank>http://www.saxonica.com/</A></FONT></SPAN> </DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,255) 2px solid; MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:talk-bounces@x-query.com"
target=_blank>talk-bounces@x-query.com</A> [mailto:<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:talk-bounces@x-query.com"
target=_blank>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
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:talk@x-query.com"
target=_blank>talk@x-query.com</A><BR><B>Subject:</B> [xquery-talk] about
"module" 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=" <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TestModules/moduleA"
target=_blank>http://www.w3.org/TestModules/moduleA</A>";<BR>import schema
namespace simple="<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/XQueryTest/simple" target=_blank>
http://www.w3.org/XQueryTest/simple</A> " at "schema_a.xsd";<BR>declare
function ma:funcA()<BR>{<BR> "40" cast as
simple:myType<BR>};<BR><BR>b.xq:<BR><BR>declare namespace mb=" <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TestModules/moduleB"
target=_blank>http://www.w3.org/TestModules/moduleB </A>";<BR>import
module namespace ma="<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TestModules/moduleA"
target=_blank>http://www.w3.org/TestModules/moduleA</A>" at "
a.xq";<BR>import schema namespace simple=" <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/XQueryTest/simple"
target=_blank>http://www.w3.org/XQueryTest/simple</A>" at
"schema_b.xsd";<BR><BR>declare function mB:funcB()<BR>{<BR>
ma:funcA() instance of
simple:myType<BR>};<BR><BR><result>{mb:funcB()}</result><BR><BR>schema_a.xsd:
<BR><BR><xs:schema xmlns:xs="<A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/2001/XMLSchema"
target=_blank>http://www.w3.org/2001/XMLSchema</A>"<BR>
xmlns:simple=" <A onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/XQueryTest/simple"
target=_blank>http://www.w3.org/XQueryTest/simple
</A>"<BR>
targetNamespace="<A onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/XQueryTest/simple"
target=_blank>http://www.w3.org/XQueryTest/simple</A>"<BR>
elementFormDefault="qualified" attributeFormDefault="qualified"
<BR>><BR> <xs:simpleType name =
"myType"><BR> <xs:restriction base =
"xs:int"><BR> <xs:minInclusive value =
"1"/><BR> <xs:maxInclusive value =
"50"/> <BR> </xs:restriction><BR>
</xs:simpleType>
<BR></xs:schema><BR><BR>schema_b.xsd:<BR><BR><xs:schema
xmlns:xs=" <A onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/2001/XMLSchema"
target=_blank>http://www.w3.org/2001/XMLSchema
</A>"<BR>
xmlns:simple="<A onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/XQueryTest/simple"
target=_blank>http://www.w3.org/XQueryTest/simple</A>"<BR>
targetNamespace=" <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/XQueryTest/simple"
target=_blank>http://www.w3.org/XQueryTest/simple
</A>"<BR>
elementFormDefault="qualified"
attributeFormDefault="qualified"<BR>><BR>
<redefine<BR>
schemaLocation="schema_a.xsd"><BR> <extension
base="simple:myType"> <BR>
<xs:minInclusive value =
"51"/><BR>
<xs:maxInclusive value = "100"/><BR>
</extension><BR>
</redefine><BR></xs:schema><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's imported schema definition?<BR><BR>This case is related with
how to understand the XQuery's "module". <BR><BR>Let me give my
understanding:<BR></FONT>XSLT's module, in my understanding, should be
"included" in <BR>another module to compile, could not be compiled
independently,<BR>in other words, it's a "white box", its semantic
<BR>depends on where it's included or imported(because its schema type
could be <BR>differently redefined in different including or importing
module).<BR> <BR>While I think XQuery's module is different with
XSLT's module, I think XQuery spec. <BR>allow its module be compiled
independently, no matter where the module is imported,<BR>module's
semantic should not be changed, in other words, XQuery's module<BR>is a
"black box", wherever module is imported, module'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
"A <A title="module import"
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TR/xquery/#dt-module-import" target=_blank>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"
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TR/xquery/#dt-issd" target=_blank>in-scope schema
definitions</A> or <A title="statically known namespaces"
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TR/xquery/#dt-static-namespaces"
target=_blank>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." <BR><BR>Here
XQuery's statement is clearly different with XSLT's statement about module
import. <BR>In XSLT spec, module imports are transitive while XQuery
clearly stated that they <BR>are not, so XQuery's module import must be
something different with XSLT's module import.<BR>My thought is, XQuery's
module is a "black box" while XSLT's module is a "white box"<BR><BR>2 "It
is a <A title="static error"
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TR/xquery/#dt-static-error" target=_blank>static
error</A> [<A title=err:XQST0036
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TR/xquery/#ERRXQST0036"
target=_blank>err:XQST0036</A>] to import a module if the importing
module's <A title="in-scope schema type"
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.w3.org/TR/xquery/#dt-is-types" target=_blank>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."<BR><BR>Here spec. force user to
import interface needed schema types, if we consider XQuery's<BR>module as
"white box", then all imported types in "white box" has already imported,
then <BR>this statement seems <SPAN style="MARGIN-RIGHT: 15px"></SPAN>lead
to redundancy, however if we consider XQuery's module<BR>as a "black box",
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></BLOCKQUOTE></BODY></HTML>