2011-03-24 68 views
1

我正在嘗試編寫我的第一個xsd模式,並且遇到了問題。我想出了最簡單的XSD我可以...但它不驗證。我在這裏做錯了什麼?爲什麼這個簡單的XSD無法驗證?

Linux命令提示符:

[email protected]:~$ 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> 

回答

3

的XML命名空間是錯在你的例子。試試這個...

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

啊,我在那裏看到了「w3」,完全忽略它不是「w3.org」。謝謝您的幫助! – 2011-03-24 17:49:22

+0

沒問題......很高興幫助 – 2011-03-24 17:54:21

+0

個人而言,我會避免像瘟疫這樣的w3schools。 http://w3fools.com/ – 2011-03-24 17:55:08

1

您的模式正在尋找「http://www.w3schools.com」命名空間的配置元素。 XML中的配置元素沒有namepsce。

相關問題