0

似乎无法修复我的代码。我收到此错误,指出文件末尾有额外内容

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Catalog [
<!ELEMENT Catalog (Movie+)>
<!ELEMENT Movie (Title,Year,Length,TopBilledActors)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Year (#PCDATA)>
<!ELEMENT Length (#PCDATA)>
<!ELEMENT TopBilledActors (#PCDATA)>
<!ATTLIST Movie movieID ID #REQUIRED>
<!ATTLIST Movie genre (Drama|Fantasy|Action|Comedy) #REQUIRED>
<!ATTLIST Movie earningsrank CDATA #IMPLIED>
]>
4

1 回答 1

0

Maybe you write a file.dtd! If i try to write this code into a DTD file I get this error (extra content at the end of the file):

test.dtd

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Catalog [
<!ELEMENT Catalog (Movie+)>
<!ELEMENT Movie (Title,Year,Length,TopBilledActors)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Year (#PCDATA)>
<!ELEMENT Length (#PCDATA)>
<!ELEMENT TopBilledActors (#PCDATA)>
<!ATTLIST Movie movieID ID #REQUIRED>
<!ATTLIST Movie genre (Drama|Fantasy|Action|Comedy) #REQUIRED>
<!ATTLIST Movie earningsrank CDATA #IMPLIED>
]>

But if i write a xml file it work fine (and nothing error):

test.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Catalog [
<!ELEMENT Catalog (Movie+)>
<!ELEMENT Movie (Title,Year,Length,TopBilledActors)>
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Year (#PCDATA)>
<!ELEMENT Length (#PCDATA)>
<!ELEMENT TopBilledActors (#PCDATA)>
<!ATTLIST Movie movieID ID #REQUIRED>
<!ATTLIST Movie genre (Drama|Fantasy|Action|Comedy) #REQUIRED>
<!ATTLIST Movie earningsrank CDATA #IMPLIED>
]>
<Catalog>
    <Movie movieID="a123" genre="Drama">
    <Title></Title>
    <Year></Year>
    <Length></Length>
    <TopBilledActors></TopBilledActors>
</Movie></Catalog>
于 2013-09-19T12:56:36.607 回答