XML Schema include 元素
定義和用法
include 元素用于向一個(gè)文檔添加帶有相同目標(biāo)命名空間的多個(gè) schema。
元素信息
| 出現(xiàn)次數(shù) | 無(wú)限制 |
| 父元素 | schema |
| 內(nèi)容 | annotation |
語(yǔ)法
<include id=ID schemaLocation=anyURI any attributes > (annotation?) </include>
| 屬性 | 描述 |
|---|---|
| id | 可選。規(guī)定該元素的唯一的 ID。 |
| schemaLocation | 必需。規(guī)定在包含 schema 的目標(biāo)命名空間中,要包括的 schema 的 URI。 |
| any attributes | 可選。規(guī)定帶有 non-schema 命名空間的任何其他屬性。 |
(? 符號(hào)聲明在 include 元素中,該元素可出現(xiàn)零次或一次。)
實(shí)例
通過(guò)被包括的 schema,被包括的文件必須全部引用相同的目標(biāo)命名空間。如果 schema 目標(biāo)命名空間不匹配,則包括不會(huì)有效:
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.dhdzp.com/schema"> <xs:include schemaLocation="http://www.dhdzp.com/schema/customer.xsd"/> <xs:include schemaLocation="http://www.dhdzp.com/schema/company.xsd"/> .. .. .. </xs:schema>