给定下一个 XML 代码:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hotels SYSTEM "travel.dtd">
<hotels>
<general>
<city>MoscowCity</city>
<address>Sherman23</address>
<phone>423423432423</phone>
<hotelDetails>
<hotel_code>1</hotel_code>
<hotel_rank>3</hotel_rank>
<hotel_name>Jacky</hotel_name>
</hotelDetails>
</general>
</hotels>
<!DOCTYPE guests SYSTEM "travel.dtd"> // HERE Validation problem
<guests>
<guest>
<id>00000001-0</id>
<guestDetails>
<name>Jones</name>
<city>SomewhereOnlyWeKnow</city>
<address>NiceStreet</address>
<state>NiceState</state>
</guestDetails>
</guest>
</guests>
及其 DTD 文件:
<?xml version="1.0" encoding="utf-8"?>
<!ELEMENT hotels (general+)>
<!ELEMENT general (city, address, phone, hotelDetails)>
<!ELEMENT hotelDetails (hotel_code, hotel_rank, hotel_name)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT hotel_rank (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT hotel_code (#PCDATA)>
<!ELEMENT hotel_name (#PCDATA)>
<!ELEMENT guests (guest+)>
<!ELEMENT guest (id, guestDetails)>
<!ELEMENT guestDetails (name, city, address, state)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT state (#PCDATA)>
该文件不会得到验证,并且 XMLspy 输出是:
Character 'D' is grammatically unexpected
知道这意味着什么吗?
谢谢!