"架构必须以<架构>开头.命名空间“http://www.w3.org/2001/XMLSchema"中的元素错误? [英] "Schema has to begin with a <schema> element in namespace 'http://www.w3.org/2001/XMLSchema'" Error?
问题描述
当尝试在 XML 间谍中显示 XML 架构时,我收到以下错误."架构必须以命名空间 'http://www.w3.org/中的元素开头2001/XMLSchema'"
When attempting to display the XML Schema in XML spy I get the following error. "Schema has to begin with a element in namespace 'http://www.w3.org/2001/XMLSchema'"
我用一个简单的示例 xml 进行了尝试并得到相同的错误
I tried it with a simple sample xml and get the same error
<?xml version="1.0"?>
<Book xmlns:lib="http://www.library.com">
<lib:Title>Sherlock Holmes</lib:Title>
<lib:Author>Arthur Conan Doyle</lib:Author>
</Book>
有什么想法吗?
推荐答案
您包含的示例是一个实例文档;它不是一个模式.架构将以如下内容开头:
The example you've included is an instance document; it is not a schema. A schema would begin with something like:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:lib="http://www.library.com"
targetNamespace="http://www.library.com"
elementFormDefault="qualified">
您的示例文档不一定格式错误,但不寻常的是它需要两个架构来验证:一个用于 http://www.library.com 命名空间,还有一个用于 Book 元素的无命名空间.
Your example document is not necessarily malformed, but is unusual in that it would require two schema to validate: one for the http://www.library.com namespace, and one in no namespace for the Book element.
我建议阅读 XMLSchema Primer.
这篇关于"架构必须以<架构>开头.命名空间“http://www.w3.org/2001/XMLSchema"中的元素错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!