W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2011

Re: What is the set of "in-scope schemas" for a reference (such as a reference to a substitution element)?

From: Michael Kay <mike@saxonica.com>
Date: Sun, 25 Sep 2011 20:32:22 +0100
Message-ID: <4E7F81C6.1030709@saxonica.com>
To: xmlschema-dev@w3.org
First, if you're concerned about terminology, then you need to 
distinguish between a schema and a schema document. A schema is a set of 
schema components, which are usually constructed by compiling a set of 
schema documents. I think that all your uses of "schema" and "schema 
file" in your question should be "schema document".

"subway", if it resolves at all, resolves to a schema component. Schema 
components are not "located in" schema documents, but they very often 
correspond to elements found in schema documents.

Your schema could still be usable if "subway" doesn't resolve at all. 
The spec is clear that failure to resolve a component reference is not 
an error, though it may render the component that contains the 
unresolved reference useless for validation purposes.

If "subway" does resolve, then the only condition is that there must be 
an element of this declaration somewhere in the schema. Processors have 
a lot of discretion as to how a schema is assembled - for example, they 
might have in-built knowledge of some components, in which case 
references to those components may resolve even if you provide no schema 
document containing a definition. For example, the Saxon schema 
processor has built-in knowledge of the components in the XML namespace. 
(However, to reference such a component, you must import the namespace).

Michael Kay

On 25/09/2011 14:31, Costello, Roger L. wrote:
> Hi Folks,
> The following no-namespace schema includes three schemas and it declares a metro element that is substitutable for a subway element:
> metro.xsd
> -----------------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>      <xs:include schemaLocation="A.xsd" />
>      <xs:include schemaLocation="B.xsd" />
>      <xs:include schemaLocation="C.xsd" />
>      <xs:element name="metro" substitutionGroup="subway" />
> </xs:schema>
> -----------------------------------------------------------------------------
> Where is the subway element? Where *could* it be located? That is, what schema files could it be located in?
> Answer: it could be located in A.xsd, B.xsd, C.xsd, or any schema file they include. Also, if metro.xsd is included by parent.xsd, then the subway element may be located in parent.xsd or any schema it includes. Further, if parent.xsd is included by grandparent.xsd, then the subway element may be located in grandparent.xsd or any schema it includes. Also for great-grandparent.xsd, great-great-grandparent.xsd, and so on.
> I will use the term "in-scope schemas" to refer to all the schemas that could contain the subway element.
> Definition of in-scope-schemas:
> The in-scope schemas for schema s are:
> 1. s
> 2. for each included schema, s'
>           in-scope schemas s'
> 3. for the schema, p, that includes s:
>          in-scope schemas p
> Note: by "included schema" I mean xs:include, xs:redefine, and xs:override.
> 1. Is "in-scope schemas" the right term?
> 2. Is my definition of in-scope schemas complete and correct?
> /Roger
Received on Sunday, 25 September 2011 19:32:46 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:00 UTC