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