Ryan Gooler
Ryan Gooler

Reputation: 2065

Why does this simple XSD not validate?

I'm trying to write my first xsd schema, and have run into an issue. I came up with the simplest XSD I could... but it doesn't validate. What am I doing wrong here?

linux command prompt:

user@computer:~$ xmllint --valid --schema test.xsd test.xml
<?xml version="1.0"?>
<!DOCTYPE configuration SYSTEM "test.dtd">
<configuration/>
test.xml:3: element configuration: Schemas validity error : Element 'configuration': No matching global declaration available for the validation root.
test.xml fails to validate

test.xml

<?xml version="1.0" ?>
<!DOCTYPE configuration SYSTEM "rcXMLAPI.dtd">
<configuration/>

test.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementFormDefault="qualified">

<xs:element name="configuration">
</xs:element>

</xs:schema>

Upvotes: 1

Views: 3521

Answers (2)

James Walford
James Walford

Reputation: 2953

Your schema is looking for a configuration element from the "http://www.w3schools.com" namespace. Your configuration element in your XML has no namepsce.

Upvotes: 1

Matthew Whited
Matthew Whited

Reputation: 22443

The XML namespace is wrong on your example. Try this instead...

   <?xml version="1.0" ?> 
   <!DOCTYPE configuration SYSTEM "rcXMLAPI.dtd"> 
   <configuration xmlns="http://www.w3schools.com" />  

Upvotes: 3

Related Questions