xmllint 验证错误“未找到 DTD"使用 XSD 时 [英] xmllint validation error "no DTD found" while using XSD
本文介绍了xmllint 验证错误“未找到 DTD"使用 XSD 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 xmllint 来检查我的工作,同时开发一个基本的 XSD,即 XML Schema 模式.但是它给了我一个错误
I'm trying to use xmllint to check my work while developing a basic XSD i.e. XML Schema schema. However it's giving me an error
验证失败:未找到 DTD.
Validation failed: no DTD found.
我做错了什么?
我的 xmllint 命令:
My xmllint command:
xmllint --noout --valid --schema simple.xsd lucas-basic.xml
lucas-basic.xml:5: validity error : Validation failed: no DTD found !
>
^
lucas-basic.xml validates
测试 XSD 文件:
<?xml version = "1.0" encoding = "UTF-8"?>
<!--Generated by XML Authority. Conforms to w3c http://www.w3.org/2001/XMLSchema-->
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
<xsd:element name = "vehicles">
<xsd:complexType>
<xsd:sequence>
<xsd:element name = "nickname" type = "xsd:string" maxOccurs = "unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
测试 XML 文件:
<?xml version="1.0"?>
<vehicles
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation = "http://lucas.ucs.ed.ac.uk/xml-schema/xmlns/simple.xsd"
>
<nickname>Bog Hopper</nickname>
<nickname>Wee Beastie</nickname>
<nickname>Count Zero</nickname>
</vehicles>
xsi:noNamespaceSchemaLocation 处的 URL 确实返回了上述 XSD.另外,我下载了xsd文件并将其放入当前目录作为额外措施,但这似乎没有改变任何东西.
The URL at xsi:noNamespaceSchemaLocation does return the above XSD. Also, I downloaded the xsd file and put it into the current directory as an extra measure, but this didn't seem to have changed anything.
推荐答案
--valid
适用于 DTD,而非 XSD.
--valid
is for DTDs, not XSDs.
这对你有用:
xmllint --noout --schema http://lucas.ucs.ed.ac.uk/xml-schema/xmlns/simple.xsd lucas-basic.xml
这篇关于xmllint 验证错误“未找到 DTD"使用 XSD 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文