2013-10-14 82 views
0

我做了一個XML文件和XML模式進行驗證。我試過了,但它給我一些錯誤。驗證器顯示我一些錯誤

XML文件格式正確,XML Schema也格式良好。但是當我嘗試使用XSD驗證XML時,它會給我一些錯誤。 圖片:LINK

當我在XSD改線2:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com"> 

它給了我另一個錯誤圖片:LINK

你能不能幫我在哪裏,我在做的錯誤嗎?


從2013年10月14日10:57更新(從答案複製):

對不起,我有點勞累過度,我不知道,我已經缺失書標籤。但是,它仍然給我一個錯誤。我仍然做錯了什麼?我附加了我的XML和XML模式。

<?xml version="1.0"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com"> 
    <xs:element name="library"> 
    <xs:complexType> 
    <xs:sequence> 
    <xs:element name="book"/> 
    <xs:element name="book_id" type="xs:integer"/> 
    <xs:element name="title" type="xs:string"/> 
    <xs:element name="author" type="xs:string"/> 
    <xs:element name="count" type="xs:integer"/> 
    <xs:element name="genre" type="xs:string"/> 
    </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 



<?xml version="1.0"?> 
    <library> 
    <book> 
    <book_id>5</book_id> 
    <title>Sokak</title> 
    <author>Tony</author> 
    <count>6</count> 
    <genre>epic</genre> 
    </book> 
    <book> 
    <book_id>13</book_id> 
    <title>Kucharka</title> 
    <author>Fiona</author> 
    <count>8</count> 
    <genre>Hobby</genre> 
    </book> 
</library> 
+1

您在xsd中沒有書籍元素 –

+0

我認爲您的架構不能準確反映結構。一個庫包含一個稱爲book的複雜類型序列,其中包含書籍ID和標題等元素。這不是你的模式所說的。 –

回答

0

託尼霍普金森給你的答案,但並沒有標記爲答案。您在xsd中沒有書籍元素。

+0

很值得回答。也許我們應該有一個叫Doh的標籤! :) –