我試圖寫一個XSD文件這個XSD究竟在哪裏出錯?
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:books" xmlns:bks="urn:books">
<xsd:element name="Books" type="bks:BooksForm"/>
<xsd:complexType name="BooksForm">
<xsd:sequence>
<xsd:element name="Book" type="bks:BookForm" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="BookForm">
<xsd:sequence>
<xsd:element name="Author" type="bks:AuthorForm" minOccurs="1" /><!--1-->
<xsd:element name="Isbn" type="xsd:string" minOccurs="1" />
<xsd:element name="Title" type="xsd:string" minOccurs="1" />
<xsd:element name="Publisher" type="xsd:string" minOccurs="1" />
<xsd:element name="YearValue" type="bks:YearForm" minOccurs="1" /><!--2-->
</xsd:sequence>
<xsd:attribute name="Cover" type="xsd:string"/>
</xsd:complexType>
<xsd:complexType name="AuthorForm">
<xsd:sequence>
<xsd:element name="Name" type="bks:NameForm"/><!--1-->
<xsd:element name="Contact" type="bks:ContactForm"/> <!--2-->
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="YearForm">
<xsd:sequence>
<xsd:element name="Year" type="xsd:integer"/><!--1-->
</xsd:sequence>
<xsd:attribute name="Edition" type="xsd:integer"/>
</xsd:complexType>
<xsd:complexType name="NameForm">
<xsd:sequence>
<xsd:element name="First" type="xsd:string"/><!--1-->
<xsd:element name="Last" type="xsd:string"/> <!--2-->
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ContactForm">
<xsd:sequence>
<xsd:element name="Phone" type="xsd:string"/><!--1-->
</xsd:sequence>
<xsd:attribute name="Office" type="xsd:string"/>
</xsd:complexType>
</xsd:schema>
與下面的XML文檔
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="Courses.xsl"?>
<Books>
<Book Cover="Paper back">
<Isbn>978-1-4652-0558-2</Isbn>
<Title>Service-Oriented Computing</Title>
<Author>
<Name>
<First>John</First>
<Last>Doe</Last>
</Name>
<Contact Office="BY400">
<Phone>480-965 000</Phone>
</Contact>
</Author>
<Publisher>Kendall Hunt</Publisher>
<Year Edition="3">
<Year>2012</Year>
</Year>
</Book>
....</Books>
但是我得到了下面的錯誤匹配,當我嘗試在線驗證它
Line 3, 8 cvc-elt.1.a: Cannot find the declaration of element 'Books'.
但據我所知,我宣佈正確。任何人都可以指出我在這裏做錯了什麼?謝謝
你可以添加定義書籍的xsd到這個問題嗎? – 2013-04-03 19:51:29
林不知道是否遺漏了一些東西,因爲我是新來的XML和XSD,但只有一個XSD和它的相應的XML。 – KodeSeeker 2013-04-03 19:53:36