我应该为XML文档创建一个XSD架构。我正在听讲座中的例子,但是当我尝试使用在线验证器时,我得到了很多“src-resolve:无法将名称'TypeSource'解析为(n)'simpleType definition'组件。”错误等。我试图搜索互联网,但到目前为止我一无所获。如果有人能帮助我,我真的很感激:
XML文件:
<?xml version="1.0" encoding="utf-8" ?>
<stephen_king_books>
<personal_data>
<name>XYZ</name>
<surname>XYZ</surname>
<gender>Mężczyzna</gender>
<age birth_month="January">19</age>
<town hometown="Bielsko-Biała">XYZ</town>
<nationality>XYZ</nationality>
<field_of_study>Informatyka Stosowana</field_of_study>
<term>1</term>
<dean_group album_number="199926">XYZ</dean_group>
</personal_data>
<copyright xmlns:xsd="http://www.uek.krakow.pl/">Wydział Zarządzania, Uniwersytet Ekonomiczny, Kraków</copyright>
<books>
<book>
<name>Carrie</name>
<year>1974</year>
<genre>Horror, Fantasy, Drama</genre>
<price currency="USD" source="https://www.amazon.com/">$7.19</price>
<rating source="https://www.goodreads.com/">3.91/5</rating>
</book>
<book>
<name>Desperation</name>
<year>1997</year>
<genre>Psychological, Horror, Thriller</genre>
<price currency="USD" source="https://www.amazon.com/">$8.99</price>
<rating source="https://www.goodreads.com/">3.80/5</rating>
</book>
<book>
<name>Doctor Sleep</name>
<year>2013</year>
<genre>Horror, Fantasy, Thriller</genre>
<price currency="USD" source="https://www.amazon.com/">$7.48</price>
<rating source="https://www.goodreads.com/">4.10/5</rating>
</book>
<book>
<name>Dolores Claibone</name>
<year>1992</year>
<genre>Thriller, Mystery, Drama</genre>
<price currency="USD" source="https://www.amazon.com/">$7.64</price>
<rating source="https://www.goodreads.com/">3.79/5</rating>
</book>
<book>
<name>Firestarter</name>
<year>1981</year>
<genre>Horror, Science Fiction, Thriller</genre>
<price currency="USD" source="https://www.amazon.com/">$7.19</price>
<rating source="https://www.goodreads.com/">3.83/5</rating>
</book>
<book>
<name>Just After Sunset</name>
<year>2008</year>
<genre>Horror, Short Stories, Fiction</genre>
<price currency="USD" source="https://www.amazon.com/">$8.09</price>
<rating source="https://www.goodreads.com/">3.84/5</rating>
</book>
<book>
<name>Shawshank Redemption</name>
<year>1982</year>
<genre>Fiction, Short Stories, Drama</genre>
<price currency="USD" source="https://www.amazon.com/">$8.64</price>
<rating source="https://www.goodreads.com/">4.51/5</rating>
</book>
<book>
<name>Pet Sematary</name>
<year>1983</year>
<genre>Thriller, Horror, Mystery</genre>
<price currency="USD" source="https://www.amazon.com/">$8.09</price>
<rating source="https://www.goodreads.com/">3.89/5</rating>
</book>
<book>
<name>The Mist</name>
<year>1980</year>
<genre>Horror, Science Fiction, Fantasy</genre>
<price currency="USD" source="https://www.amazon.com/">$6.01</price>
<rating source="https://www.goodreads.com/">3.90/5</rating>
</book>
<book>
<name>The Shining</name>
<year>1980</year>
<genre>Horror, Thriller, Mystery</genre>
<price currency="USD" source="https://www.amazon.com/">$5.39</price>
<rating source="https://www.goodreads.com/">4.15/5</rating>
</book>
</books>
XSD架构:
<?xml version="1.0" encoding="utf-8"?>
<!--XYZ -->
<xsd:element name="stephen_king_books">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="personal_data" type="PersonalType" maxOccurs="unbounded"/>
<xsd:element name="copyright" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="books" type="BooksType" minOccurs="1" maxOccurs="unbounded"/>
<xsd:element name="book" type="BookType" minOccurs="10" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="BooksType">
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="book" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="AgeType">
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="birth_month"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="PersonalType">
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="surname" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="gender" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="age" type="AgeType" maxOccurs="unbounded"/>
<xsd:element name="town" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="nationality" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="field_of_study" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="term" type="xsd:string" maxOccurs="unbounded"/>
<xsd:element name="dean_group" type="xsd:string" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="birth_month" type="xsd:string"/>
<xsd:attribute name="hometown" type="xsd:string"/>
<xsd:attribute name="album_number" type="xsd:string"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="BookType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="year" type="xsd:string"/>
<xsd:element name="genre" type="xsd:string"/>
<xsd:element name="price" type="xsd:string"/>
<xsd:element name="rating" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="currency" type="xsd:string" use="required"/>
<xsd:attribute name="source" type="xsd:string" use="required"/>
<xsd:attribute name="from" type="xsd:string" use="required"/>
</xsd:complexType>