我目前正在学习XML,并且正在尝试创建一个表示库的简单XML文件。我收到的无效内容从XML中的元素“ librarian”错误开始。我知道以前曾有人问过同样的问题,但是他们的回答并不能解决我的问题,因为我似乎还有其他原因。 我的XSD文件如下
<?xml version="1.0"?>
<xs:schema version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.mybooks.org"
xmlns="http://www.mybooks.org"
elementFormDefault="qualified">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="librarian">
<xs:complexType>
<xs:attribute name="name" use="required"/>
<xs:attribute name="email" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="book" minOccurs = "1" maxOccurs = "unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="part" minOccurs = "1" maxOccurs = "unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="chapter" minOccurs = "1" maxOccurs = "unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="section" minOccurs = "1" maxOccurs = "unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="paragraph" type="xs:string" minOccurs = "1" maxOccurs = "unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="title" use="required"/>
<xs:attribute name="summary" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="title" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="title" use="required"/>
<xs:attribute name="isbn" use="required"/>
<xs:attribute name="author" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="location" use="required"/>
<xs:attribute name="description" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
我的XML文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<myDay:library xmlns:myDay ="http://www.mybooks.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mybooks.org library.xsd" location = "Nasr City" description = "A Public Library">
<librarian name = "Islam"/>
<book title = "The Structure of Scientific Revolutions" isbn = "_100" author = "Thomas Kuhn">
<part title = "I">
<chapter title = "Paradigm" summary = "my summary">
<section>
<paragraph> normal science </paragraph>
</section>
</chapter>
</part>
</book>
</myDay:library>
我在这里做错了什么?是我在架构定义中出错还是在XML文件本身中?