[xquery-talk] about "module" in XQuery spec

he harrison harrison076 at gmail.com
Wed Jan 9 10:47:55 PST 2008

I come up with a problem when reading XQuery1.0 spec., following is my case:


module namespace ma=" http://www.w3.org/TestModules/moduleA";
import schema namespace simple=" http://www.w3.org/XQueryTest/simple " at
declare function ma:funcA()
   "40" cast as simple:myType


declare namespace mb=" http://www.w3.org/TestModules/moduleB ";
import module namespace ma="http://www.w3.org/TestModules/moduleA" at " a.xq
import schema namespace simple=" http://www.w3.org/XQueryTest/simple" at

declare function mB:funcB()
  ma:funcA() instance of simple:myType



<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:simple=" http://www.w3.org/XQueryTest/simple "
           elementFormDefault="qualified" attributeFormDefault="qualified"
  <xs:simpleType name = "myType">
     <xs:restriction base = "xs:int">
      <xs:minInclusive value = "1"/>
      <xs:maxInclusive value = "50"/>


<xs:schema xmlns:xs=" http://www.w3.org/2001/XMLSchema "
           targetNamespace=" http://www.w3.org/XQueryTest/simple "
           elementFormDefault="qualified" attributeFormDefault="qualified"
    <extension base="simple:myType">
        <xs:minInclusive value = "51"/>
        <xs:maxInclusive value = "100"/>

What would be the result of this case?
true? false? runtime error? or implementation define?
Or in another word, would the type in module a.xq should
be redefined by module c.xq's imported schema definition?

This case is related with how to understand the XQuery's "module".

Let me give my understanding:
XSLT's module, in my understanding, should be "included" in
another module to compile, could not be compiled independently,
in other words, it's a "white box", its semantic
depends on where it's included or imported(because its schema type could be
differently redefined in different including or importing module).

While I think XQuery's module is different with XSLT's module, I think
XQuery spec.
allow its module be compiled independently, no matter where the module is
module's semantic should not be changed, in other words, XQuery's module
is a "black box", wherever module is imported, module's schema type
definition should not be
affected by type redefine mechanism.

The reason why I make such conclusion is from following XQuery spec
1 "A module import <http://www.w3.org/TR/xquery/#dt-module-import> imports
only functions and variable declarations; it does not import other objects
from the imported modules, such as in-scope schema
definitions<http://www.w3.org/TR/xquery/#dt-issd>or statically
known namespaces <http://www.w3.org/TR/xquery/#dt-static-namespaces>. Module
imports are not transitive¡ªthat is, importing a module provides access only
to function and variable declarations contained directly in the imported

Here XQuery's statement is clearly different with XSLT's statement about
module import.
In XSLT spec, module imports are transitive while XQuery clearly stated that
are not, so XQuery's module import must be something different with XSLT's
module import.
My thought is, XQuery's module is a "black box" while XSLT's module is a
"white box"

2 "It is a static error <http://www.w3.org/TR/xquery/#dt-static-error> [
err:XQST0036 <http://www.w3.org/TR/xquery/#ERRXQST0036>] to import a module
if the importing module's in-scope schema
types<http://www.w3.org/TR/xquery/#dt-is-types>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."

Here spec. force user to import interface needed schema types, if we
consider XQuery's
module as "white box", then all imported types in "white box" has already
imported, then
this statement seems lead to redundancy, however if we consider XQuery's
as a "black box", then this statement is quite nature to understand.

Could someone offer me some comment?
Many thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20080109/3989b5fc/attachment.htm

More information about the talk mailing list