schemaLocation
schemaLocation 属性引用具有目标命名空间的 XML 架构文档。
<xsi:schemaLocation="list of anyURI" >
特性
- anyURI (list)
一个架构位置,该架构包含限定的(具有命名空间的架构)架构构造。每一对中的第一个 URI 引用是命名空间名称,第二个则是描述命名空间的架构的位置。
备注
该属性将具有目标命名空间的 XML 架构文档与实例文档相关联。
不要求 XML 架构有命名空间。若要为没有目标命名空间的 XML 架构指定位置,请使用 noNamespaceSchemaLocation 属性。此属性中引用的 XML 架构不能有目标命名空间。因为此属性不接受 URL 列表,所以只能指定一个架构位置。
将具有目标命名空间的架构文档与实例文档相关联。可以列出多对 URI 引用,每一对都有不同的命名空间名称部分。
根据万维网联合会 (W3C) XML 架构建议,XML 实例文档可以同时指定 xsi:schemaLocation 和 xsi:noNamespaceSchemaLocation 属性。此外,还可以多次列出同一个命名空间。
在 MSXML 6.0 中,如果您已指定 xsi:schemaLocation 并处理了来自该命名空间的元素,您就不能指定新的 xsi:schemaLocation。MSXML 6.0 对这种情况会报告错误。以前的版本不报告错误。
示例
以下示例演示如何使用 xsi:schemaLocation 特性为多个 XML 架构文档提供位置信息。
<p:Person
xmlns:p="https://contoso.com/People"
xmlns:v="https://contoso.com /Vehicles"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"https://contoso.com/People
https://contoso.com/schemas/people.xsd
https://contoso.com/schemas/Vehicles
https://contoso.com/schemas/vehicles.xsd
https://contoso.com/schemas/People
https://contoso.com/schemas/people.xsd">
<name>John</name>
<age>28</age>
<height>59</height>
<v:Vehicle>
<color>Red</color>
<wheels>4</wheels>
<seats>2</seats>
</v:Vehicle>
</p:Person>