This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12173 - Do we need [err:XQST0036] in-scope schema definitions of the importing module?
Summary: Do we need [err:XQST0036] in-scope schema definitions of the importing module?
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.0 (show other bugs)
Version: Working drafts
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-24 15:45 UTC by Jonathan Robie
Modified: 2011-04-11 21:34 UTC (History)
1 user (show)

See Also:


Attachments

Description Jonathan Robie 2011-02-24 15:45:31 UTC
In our resolution of Bug 11095, we decided to add schema components to the data model, and require implementations to know derivations contained in the data model schema.

We could make a similar decision for imported modules. [err:XQST0036] is raised if the type of an imported variable referenced in the importing module, or a parameter type or result type of an imported function referenced in the importing module, is not contained in the ISSD of the importing module.

We could eliminate this error condition, putting the burden on implementations rather than users.
Comment 1 Michael Kay 2011-02-24 16:04:28 UTC
I'm inclined to agree. At one time our spec encouraged the interpretation that the static context of a module included the schema namespaces explicitly imported into that module, and nothing else, and I went to painful lengths to ensure that a reference to a name that wasn't explicitly imported was rejected. 

We have since repudiated that interpretation in favour of the idea that the static context contains all the schema components you happen to know about at compile time, whether explicitly imported or not. This means that XQST0036 has lost most of its original point.
Comment 2 Jonathan Robie 2011-02-24 17:19:44 UTC
(In reply to comment #1)

> We have since repudiated that interpretation in favour of the idea that the
> static context contains all the schema components you happen to know about at
> compile time, whether explicitly imported or not. 

The in-scope schema definitions still come from:

1. built-in types
2. explicit schema import
3. implementation-defined additions

Module import does not import the ISSD of the imported module. And it shouldn't - a single query should be allowed to use library modules whose definitions may conflict if merged into one ISSD, e.g. library modules for various flavors of html.

So I think the effect of the proposed change is limited: 

1. Importing such a module is not an error

2. Variables and functions can be used even if their types are unknown, because their derivation is known, and the implementation can determine whether they are allowed in a given expression.
Comment 3 Jonathan Robie 2011-03-01 01:08:37 UTC
The Working Group agreed to delete the following text (excuse the formatting loss due to lack of HTML):

<delete>
It is a static error [err:XQST0036] to import a module if the in-scope schema definitions of the importing module do not include all of the following:

An in-scope schema type for each type-name that appears:
in the type of a variable that is declared in the imported module and referenced in the importing module, OR
in a parameter-type or result-type of a function that is declared in the imported module and referenced in the importing module.
An in-scope element declaration for each element-name EN such that:
schema-element(EN) appears in the declared type of a variable in the imported module, and that variable is referenced in the importing module, OR
schema-element(EN) appears in a parameter-type or result-type of a function declared in the imported module, and that function is referenced in the importing module.
An in-scope attribute declaration for each attribute-name AN such that:
schema-attribute(AN) appears in the declared type of a variable in the imported module, and that variable is referenced in the importing module, OR
schema-attribute(AN) appears in a parameter-type or result-type of a function declared in the imported module, and that function is referenced in the importing module.
</delete>

And to modify this:

<changeme>
To illustrate the above rules, suppose that a certain schema defines a type named triangle. Suppose that a library module imports the schema, binds its target namespace to the prefix geometry, and declares a function with the following function signature: math:area($t as geometry:triangle) as xs:double. If a query wishes to use this function, it must import both the library module and the schema on which it is based. Importing the library module alone would not provide access to the definition of the type geometry:triangle used in the signature of the area function.
</changme>

The modification must illustrate the interaction of types in the two ISSDs.

The following text will be kept as is:

<keep>
The following example illustrates a module import:

import module namespace math =
  "http://example.org/math-functions";
</keep>
Comment 4 Jonathan Robie 2011-03-01 19:53:21 UTC
The following examples replace the paragraph in the <changeme/> of the previous comment:


A module import does not import schema definitions from the imported
module. In the following query, the type geometry:triangle is not
defined, even if it is known in the imported module, so the variable
declaration raises an error <errorref class="ST" code="0051"/>:

  import module namespace math = "http://example.org/math-functions";
  declare variable $t as geometry:triangle := geometry:make-triangle();

  $t

Without the type declaration for the variable, the variable
declaration succeeds:

  import module namespace math = "http://example.org/math-functions";
  declare variable $t := geometry:make-triangle();

  $t

Importing the schema that defines the type of the variable, the
variable declaration succeeds:

  import schema namespace geo = "http://example.org/math-schema-declarations";
  import module namespace math = "http://example.org/math-functions";
  declare variable $t as geometry:triangle := geometry:make-triangle();

  $t
Comment 5 Jonathan Robie 2011-04-11 21:34:58 UTC
In meeting  #468, the Working Group agreed to adopt comment #3 as our resolution of this bug.