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.w3s开发者_开发问答chools.com" elementFormDefault="qualified">
<xs:element name="configuration">
</xs:element>
</xs:schema>
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" />
Your schema is looking for a configuration element from the "http://www.w3schools.com" namespace. Your configuration element in your XML has no namepsce.
精彩评论