Import/Include/Redefine

I have some questions about the intended meaning of imports, includes,
and redefines with respect to each other and also to the xsi:schemaLocation
attribute.

Here are the situations I'm unclear on, and I'm having trouble finding
specifics about this in the specs.  Pointers into the spec would be
greatly appreciated, as would a clear answer, of course.

1. Includes referencing each other: can an included document refer to things
in the including document, or in other included documents?  I assume the
answer is yes, because including should be equivalent to cutting and pasting
the document into that point in the schema.

	Example:
	Schema 1:
	<xs:schema ...>
		<xs:include schemaLocation="schema-2.xsd"/>
		<xs:element name="x"/>
	</xs:schema>

	Schema 2:
	<xs:schema ...>
		<xs:element name="y">
			<xs:sequence>
				<!-- Refer to element from schema 1 -->
				<xs:element ref="x"/>
			</xs:sequence>
		</xs:element>
	</xs:schema>

2. Imports referencing each other: can an imported document refer to
things in the importer?  The example is the same as above, only with schema 1
importing schema 2 and the appropriate targetNamespace transformations.

	Example:
	Schema 1:
	<xs:schema ...>
		<xs:import namespace="XXX" schemaLocation="schema-2.xsd"/>
		<xs:element name="x"/>
	</xs:schema>

	Schema 2:
	<xs:schema targetNamespace="XXX"...>
		<xs:element name="y">
			<xs:sequence>
				<!-- Refer to element from schema 1 -->
				<xs:element ref="x"/>
			</xs:sequence>
		</xs:element>
	</xs:schema>

3. Imports and xsi:namespaceLocation.  If schema 1 imports schema 2 
for namespace XXX, but then the document being validated has an 
xsi:namespaceLocation="XXX schema-3.xsd" (or the user specifies such a thing),
which schema takes precedence when?  I could see the following scenarios:

	a. Schema 2 is used as referenced in schema 1, but Schema 3 is used
	otherwise.  So, a document like this would be valid:

		<sample-doc xmlns="XXX" 
		xsi:namespaceLocation="XXX schema-3.xsd YYY schema-1.xsd">
			<!-- content appropriate to schema-3, but not schema-2
			-->
		</sample-doc>

	as would the following, assuming that XXX:data is a valid child of
	YYY:sample-doc, of course:

		<sample-doc xmlns="YYY" xmlns:XXX="XXX" xmlns:YYY="YYY"
		xsi:namespaceLocation="XXX schema-3.xsd YYY schema-1.xsd">
			<XXX:data>
			<!-- content appropriate to schema-2, but not schema-3
			-->
			</XXX:data>
		</sample-doc>


	b. Schema 2 is always used.

	c. Schema 3 is always used.

	d. Schema 3 is always used if the user said so, but not if the
	input document declared it.

	e. Processor dependent.

4. Imports and top elements: if schema 1 imports schema 2, can a global element
from schema 2 kick off a document?  That is, with the following schema:

	Example:
	Schema 1:
	<xs:schema targetNamespace=""...>
		<xs:import namespace="XXX" schemaLocation="schema-2.xsd"/>
		<xs:element name="x"/>
	</xs:schema>

	Schema 2:
	<xs:schema targetNamespace="XXX"...>
		<xs:element name="y">
			<xs:sequence>
				<!-- Refer to element from schema 1 -->
				<xs:element ref="x"/>
			</xs:sequence>
		</xs:element>
	</xs:schema>

	is this a valid input document?

	<XXX:y xmlns:XXX="XXX"><x/><XXX:y>



thank you very much,
niko

Received on Friday, 11 January 2002 15:50:28 UTC