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>
Attribute | 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 of the containing schema. |
any attributes | Optional. Specifies any other attributes with a non-schema namespace. |
(? Symbol declarations are in the include element, which can appear zero or once.)
Instance
The included files must all refer to the same target namespace by being included in the schema. 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>