xs:include
<xs:include id = "ID
" schemaLocation = "anyURI
"> <!-- (annotation?) --> </xs:include>
The top-level xs:include
element is used to divide a schema into multiple
separate documents. The schemaLocation
attribute contains a
relative or absolute URI pointing to the schema document to
include. It differs from xs:import
in that all included files
describe the same target namespace.
There is no limit to inclusion depth. Schema A can include
schema B, which itself includes schema C and schema D. In such a
case, schema A can use definitions and declarations from all four
documents. Even recursion (schema A includes schema B, which
includes schema A) is not prohibited, although it is strongly
discouraged. Instance documents would refer only to the top-level
schema A in their xsi:schemaLocation
or xsi:noNamespaceSchemaLocation
attribute.
Validation is performed after all includes are resolved. If
there are any conflicts between the including schema and an
included schema—for instance, one schema declares that the
FullName
element has a simple
type, and another declares that the FullName
element has a complex type—then
the schema is in error and cannot be used. Most of the time,
schemas should be carefully managed so that each element and type
is defined in exactly one schema document.