Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

xml - xmllint validation error "no DTD found" while using XSD

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

Validation failed: no DTD found.

What am I doing wrong?

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

Test XSD file:

<?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>

Test XML file:

<?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>

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

--valid is for DTDs, not XSDs.

This will work for you instead:

xmllint --noout --schema http://lucas.ucs.ed.ac.uk/xml-schema/xmlns/simple.xsd lucas-basic.xml

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...