0

我制作了一个 XML 文件和 XML Schema 进行验证。我试过了,但它给了我一些错误。

XML 文件格式正确,XML Schema 格式也正确。但是当我尝试使用 XSD 验证 XML 时,它给了我一些错误。图片:链接

当我将 XSD 中的第 2 行更改为:

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

它给了我另一个错误图片:链接

你能帮我在哪里犯错吗?


从 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>
4

1 回答 1

0

托尼·霍普金森(Tony Hopkinson)已给您答案,但并未将其标记为答案。您在 xsd 中没有 book 元素。

于 2013-10-14T06:58:47.493 回答