【发布时间】:2014-09-29 16:29:16
【问题描述】:
我尝试通过 c# 和 xsd 数据验证 docbook 5.0 xml。
我从这里的示例开始:http://msdn.microsoft.com/en-us/library/ckztbtx6(v=vs.110).aspx,它非常简单。 我使 notValidXSD.xml(在示例中)有效,删除了第一本书调用它 nowValidXSD.xml 并且它的文字很好。
现在我尝试了同样的 Docbook 5.0 格式(docbook.xsd、xml.xsd xlink.xml),您可以在此处下载 http://www.docbook.org/xml/5.0/xsd/
尝试代码(由上面 msdn 上的示例给出)给了我:
Validating XML file mydocxml.xml
Validation error: the http ://www.w3.org/XML/1998/namespace:id-Attribute is not declared.
Validation error: the http ://docbook.org/ns/docbook:article-Element is not declared.
Validation error: the schema informationen für das Attribute 'version' could not be found.
Validation error: the http://docbook.org/ns/docbook:title-Element is not declared.
Validation error: the http://docbook.org/ns/docbook:para-Element is not declared.
Validation finished. Validation failed.
(我必须在 http 之后留出空格,因为这是我的第一个问题) 我不知道该怎么办了。对我来说,这些文件看起来不错。我用谷歌搜索了几个小时的问题,但似乎无法通过 c# 进行验证。
这里是文件:
<!-- nowValidXSD.xml -->
<?xml version='1.0' encoding="UTF-8"?>
<bookstore xmlns="urn:bookstore-schema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:bookstore-schema books.xsd">
<book genre="novel">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
</bookstore>
还有文档 xml:
<!-- mydocxml.xml -->
<?xml version="1.0" encoding="UTF-8"?> <!-- -->
<article xmlns="http ://docbook.org/ns/docbook" version="5.0"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http ://docbook.org/ns/docbook docbook.xsd">
<title>some title</title>
<para> some text.</para>
</article>
【问题讨论】:
标签: c# xml validation xsd docbook