2017-09-15 45 views
0

我无法验证我的XML文档。我收到一条错误消息The Value Of Attribute "xmlns:xs" Associated With An Element Type "xs:schema" Must Not Contain The '<' Character.我在代码中找不到任何语法错误。无法验证XML文档。 “xs:schema”必须不包含'<'字符

这是我的XML代码:

<?xml version="1.0" encoding="utf-8"?> 
 
<bookstore> 
 
<book> 
 
    <title>The Hunger Games</title> 
 
    <author>Suzzanne Collins</author> 
 
    <price>299</price> 
 
</book> 
 
<book> 
 
    <title>Divergent</title> 
 
    <author>Veronica Roth</author> 
 
    <price>399</price> 
 
</book> 
 
<book> 
 
    <title>Me Before you</title> 
 
    <author>JoJoMoyes</author> 
 
    <price>299</price> 
 
</book> 
 
</bookstore>

,这是XSD文件:

<?xml version="1.0"?> 
 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema> 
 
<xs:element name="bookstore"> 
 
    <xs:complexType> 
 
    <xs:sequence> 
 
    <xs:element name="book" maxOccurs="unbounded"> 
 
    <xs:complexType> 
 
     <xs:sequence> 
 
     <xs:element name="title" type="xs:string"/> 
 
     <xs:element name="author" type="xs:string"/> 
 
     <xs:element name="price" type="xs:integer"/> 
 
     </xs:sequence> 
 
    </xs:complexType> 
 
    </xs:element> 
 
    </xs:sequence> 
 
</xs:complexType> 
 
    </xs:element> 
 
</xs:schema>

回答

2

您的架构的第二行是

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

你缺少右引号,它应该是

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
相关问题