Error checking xmllint "missing DTD" when using XSD

I am trying to use xmllint to test my work when developing a basic XSD ie XML Schema. However this gives me an error

Verification Failed: DTD not 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 

Check the 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> 

Check 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 in xsi: noNamespaceSchemaLocation returns the above returned XSD. In addition, I downloaded the xsd file and placed it in the current directory as an extra measure, but that didn't seem to change anything.

+6
source share
2 answers

--valid for DTD, not for XSD.

This will work for you:

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

The OP tries and accepts the β€œverify” XSD response, checking it against a sample file. To check the XSD file for compliance with the XSD specification, you can use the following command:

 xmllint --noout --schema http://www.w3.org/2001/XMLSchema.xsd my_schema.xsd 

... and for v1.1 scheme https://www.w3.org/2009/XMLSchema/XMLSchema.xsd

NOTE. There are some recommendations in the v1.0 schema at the top of the normative framework, so you can use a different file, but this works fine for me.

-one
source

All Articles