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 a unique ID for 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. |
(? Symbol declaration is in the include element, which may appear zero or one times.)
Instance
The included files must all refer to the same target namespace included by the schema. If the schema target namespace does not match, the inclusion will not be effective:
<?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>