XML DTD 错误 AttValue: " or ' expected but validator finds no errors

XML DTD error AttValue: " or ' expected but validator finds no errors

我收到错误: 第 29 行第 33 列的错误:AttValue: " or ' expected 当我使用任何浏览器时,我都会收到此错误。但是,我使用的两个验证器没有发现任何问题。 它引用的代码行:

<!ELEMENT tune (#PCDATA)>

我觉得很奇怪,因为代码在第 29 列结束,所以第 33 列中没有代码。

完整代码如下:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE bands [
    <!NOTATION JPG SYSTEM "image/jpeg">
    <!ENTITY celtic SYSTEM "celtic.jpg" NDATA JPG>
    <!ENTITY badger SYSTEM "badger.jpg" NDATA JPG>
    <!ELEMENT bands (band)>
    <!ELEMENT band (name, city, logo?, competition)>
    <!ATTLIST band cid ID #REQUIRED>

    <!ELEMENT name (#PCDATA)>
    <!ATTLIST name grade (1|2|3|4|5|juvenile|novice) #REQUIRED>
    <!ELEMENT city (#PCDATA)>
    <!ELEMENT logo EMPTY>
    <!ATTLIST logo source ENTITY #REQUIRED>
    <!ELEMENT competition (event, event)>
    <!ELEMENT event (tune)>
    <!ATTLIST event type ENTITY (MSR | Medley) #REQUIRED>
    <!ELEMENT tune (#PCDATA)>
]>
<bands>
   <band cid="c0001">
      <name grade="juvenile">School of Celtic Bagpipes &amp; Drumming</name>
      <city>Delafield</city>
      <logo source="celtic" />
      <competition>
         <event type="MSR">
            <tune>Charlies Welcome</tune>
            <tune>Mrs MacPherson of Inveran</tune>
            <tune>Brown Haired Maiden</tune>
         </event>
         <event type="Medley">
            <tune>Rowd's Hornpipe</tune>
         </event>
      </competition>
   </band>
   <band cid="c0002">
      <name grade="juvenile">Badger Pipes and Drums</name>
      <city>Madison</city>
      <logo source="badger" />
      <competition>
         <event type="MSR">
            <tune>Lord Alexander Kennedy</tune>
            <tune>Bob of Fettercairn</tune>
            <tune>Brown Haired Maiden</tune>
         </event>
         <event type="Medley">
            <tune>Out of the Air</tune>
         </event>
      </competition>
   </band>
   <band cid="c0003">
      <name grade="novice">Pardeeville School of Piping and Drumming</name>
      <city>Pardeeville</city>
      <competition>
         <event type="MSR">
            <tune>Lord Alexander Kennedy</tune>
            <tune>Bob of Fettercairn</tune>
            <tune>The Little Cascade</tune>
         </event>
         <event type="Medley">
            <tune>The Radar Racketeer</tune>
         </event>
      </competition>
   </band>
   <band cid="c0004">
      <name grade="3">Zoar Scottish Pipe Band</name>
      <city>Zoar</city>
      <competition>
         <event type="MSR">
            <tune>Charlies Welcome</tune>
            <tune>Mrs MacPherson of Inveran</tune>
            <tune>Major Manson</tune>
         </event>
         <event type="Medley">
            <tune>Miss Lily</tune>
         </event>
      </competition>
   </band>
   <band cid="c0005">
      <name grade="juvenile">Stockholm Pipe Band</name>
      <city>Stockholm</city>
      <competition>
         <event type="MSR">
            <tune>Pretty Marion</tune>
            <tune>The Sheepwife</tune>
            <tune>Brown Haired Maiden</tune>
         </event>
         <event type="Medley">
            <tune>Farewell to Erin</tune>
          </event>
      </competition>
   </band>
</bands>

我认为问题实际上是这一行:

<!ATTLIST event type ENTITY (MSR | Medley) #REQUIRED>

您不能使用 ENTITY 和可能值的枚举。 (See here.)

你可能想要:

<!ATTLIST event type (MSR | Medley) #REQUIRED>

还有一些其他问题...

  1. 您的 XML 有 bands 的多个 band 个子元素,但内容模型只允许一个 band。您可能想要添加 + 出现指示符:
<!ELEMENT bands (band+)>
  1. 您的 XML 有 event 的多个 tune 个子元素,但内容模型只允许一个 tune。您可能想要添加 + 出现指示符:
<!ELEMENT event (tune+)>