XML Schema include element

Definition and usage

The include element is used to add multiple schemas with the same target namespace to a document.

Element information

Occurrence Unrestricted
Parent element schema
Content annotation

Syntax

<include
id=ID
schemaLocation=anyURI
any attributes
>
(annotation?)
</include>
Attributes Description
id Optional. Specifies the unique ID of the element.
schemaLocation Required. Specifies the URI of the schema to be included in the target namespace where the schema is included.
any attributes Optional. Specifies any other attributes with a non-schema namespace.

(? The symbol declaration is in the include element, which can appear zero or once.)

Instance

Through the included schema, all included files must refer to the same target namespace. If the schema target namespace does not match, the inclusion will not be valid:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.codew3c.com/schema"
<xs:include schemaLocation="http://www.codew3c.com/schema/customer.xsd"/>
<xs:include schemaLocation="http://www.codew3c.com/schema/company.xsd"/>
..
..
..
</xs:schema>