当我使用 xmllint 检查我的 DTD 文件时,我收到一条错误消息。请参阅下面的输出。我不确定这一切都出了什么问题。
book.dtd:1: parser error : StartTag: invalid element name
<!ELEMENT books_for_sale (book+)>
^
book.dtd:1: parser error : Extra content at the end of the document
<!ELEMENT books_for_sale (book+)>
^
这是我的 DTD 文件
<!ELEMENT books_for_sale (book+)>
<!ELEMENT book (book_id, title, author, co_author_name, editor_name, illustrator_name, language, ISBN, publisher, publisher_date, genre, subject, category, file_size, pages, price, payment_method)>
<!ELEMENT book_id (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT co_author_name (#PCDATA)>
<!ELEMENT editor_name (#PCDATA)>
<!ELEMENT illustrator_name (#PCDATA)>
<!ELEMENT language (#PCDATA)>
<!ELEMENT ISBN (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT publisher_date (#PCDATA)>
<!ELEMENT genre (#PCDATA)>
<!ELEMENT subject (#PCDATA)>
<!ELEMENT category (#PCDATA)>
<!ELEMENT file_size (#PCDATA)>
<!ELEMENT pages (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT payment_method (#PCDATA)>
不确定 html 和 xml 的组合是否正确完成。尝试使用命名空间来解决这个问题。但这对我来说是全新的,所以我不确定它是否写得正确。
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE books_for_sale SYSTEM "book.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:BO="http://resumator3000.com">
<!-- list book inventory -->
<head>
<title>Book Order</title>
<link rel="stylesheet" type="text/css" href="book.css"></link>
</head>
<body>
<div class="page-wrap">
<h3>Books for Sale</h3>
<h4>Great Prices! Limted Selection! No Delivery!</h4>
<!-- present books for sale -->
<BO:books_for_sale>
<BO:book>
<p>Book ID: <BO:book_id>BK12345</BO:book_id></p>
<p>Book Title: <BO:title>Gray Geese Crying</BO:title></p>
<p>Author: <BO:author>Bill Nedham</BO:author></p>
<p>Co-Author: <BO:co_author_name>Surely Joking</BO:co_author_name></p>
<p>Editor: <BO:editor_name>Fried Brian</BO:editor_name></p>
<p>Illustrator: <BO:illustrator_name>Drew Sumthin</BO:illustrator_name></p>
<p>Language: <BO:language>Orangatang</BO:language></p>
<p>ISBN: <BO:ISBN>9912385748391</BO:ISBN></p>
<p>Publisher: <BO:publisher>Random Random Homes</BO:publisher></p>
<p>Publish Date: <BO:publisher_date>2001</BO:publisher_date></p>
<p>Genre: <BO:genre>Poetry</BO:genre></p>
<p>Subject: <BO:subject>Human Mind</BO:subject></p>
<p>Category: <BO:category>Self-Help</BO:category></p>
<p>File Size: <BO:file_size>122 MB</BO:file_size></p>
<p>Pages: <BO:pages>3</BO:pages></p>
<p>Price: <span id="dollar">$</span><BO:price>142.99</BO:price></p>
<p>Payment Method: <BO:payment_method>Paypal</BO:payment_method></p>
</BO:book>
</BO:books_for_sale>
</div>
</body>
</html>
不知道哪里出了问题。