dtd错误文件末尾的额外内容

时间:2013-03-24 18:56:52

标签: xml 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>
]>

1 个答案:

答案 0 :(得分:0)

也许你写了一个文件.dtd! 如果我尝试将此代码写入DTD文件,我会收到此错误(文件末尾的额外内容):

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>
]>

但是,如果我写一个xml文件,它工作正常(并没有任何错误):

的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>