Latest web development tutorials

XML Schema include elements

XML Schema Reference Complete XML Schema Reference

Definition and Usage

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

Element Information

  • Parent element: schema

grammar

<include
id=ID
schemaLocation=anyURI
any attributes
>

(annotation?)

</include>

(? Sign declares that include element, the element can occur zero or one time.)

属性 描述
id 可选。规定该元素的唯一的 ID。
schemaLocation 必需。规定在包含 schema 的目标命名空间中,要包括的 schema 的 URI。
any attributes 可选。规定带有 non-schema 命名空间的任何其他属性。

Example 1

By being included in the schema, the file must be included in all references to the same target namespace. If the schema target namespace do not match, it will not be effective include:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3cschool.cc/schema">

<xs:include schemaLocation="http://www.w3cschool.cc/schema/customer.xsd"/>
<xs:include schemaLocation="http://www.w3cschool.cc/schema/company.xsd"/>

..

..

..

</xs:schema>


XML Schema Reference Complete XML Schema Reference