XML Schema include 元素
❮ 完整的 XML Schema 參考
定義和用法
include 元素用於在一個文件中新增具有相同目標名稱空間(target namespace)的多個 schema。
元素資訊
- 父元素: schema
語法
<include
id=ID
schemaLocation=anyURI
任何屬性
>
(annotation?)
</include>
(? 符號宣告該元素可以在 include 元素內出現零次或一次)
Attribute | 描述 |
---|---|
id | 可選。指定元素的唯一 ID |
schemaLocation | 必需。指定要包含到當前 schema 的目標名稱空間中的 schema 的 URI |
任何屬性 | 可選。指定任何其他非 schema 名稱空間的屬性 |
示例 1
使用 include 的 schema 時,被包含的檔案必須都引用相同的目標名稱空間。如果 schema 的目標名稱空間不匹配,include 將無法正常工作。
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://w3schools.tw/schema">
<xs:include schemaLocation="https://w3schools.tw/xml/customer.xsd"/>
<xs:include schemaLocation="https://w3schools.tw/xml/company.xsd"/>
..
..
..
</xs:schema>
❮ 完整的 XML Schema 參考