我正在尝试使用xmllint来检查我的工作,同时开发一个基本的XSD,即XML Schema架构.但它给了我一个错误
Validation Failed: no DTD found.
我究竟做错了什么?
我的xmllint命令:
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>
测试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文件并将其作为额外措施放入当前目录,但这似乎没有改变任何东西.
– 无效是针对DTD,而不是XSD.
原文链接:https://www.f2er.com/xml/293048.html这对你有用:
xmllint --noout --schema http://lucas.ucs.ed.ac.uk/xml-schema/xmlns/simple.xsd lucas-basic.xml