XML DTD错误AttValue:"或'预期,但验证器发现没有错误

发布于 2025-01-18 12:46:28 字数 3912 浏览 5 评论 0原文

我收到错误: 第 29 行第 33 列出现错误:AttValue:“或 ' 预期 当我使用任何浏览器时,我都会收到此错误。但是,我使用的两个验证器没有发现任何问题。 它所指的代码行:

<!ELEMENT tune (#PCDATA)>

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

这是整个代码:

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

I get the error:
error on line 29 at column 33: AttValue: " or ' expected
When I use any browser I recieve this error. However, two validators I use don't find any issues.
The line of code it is referring to:

<!ELEMENT tune (#PCDATA)>

I find it odd as there is no code in column 33 as the code ends at column 29.

Here is the entire code:

<?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 & 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

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

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

您不能使用entity以及可能的值列举。 (请参阅这里。)

您可能想要:

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

还有一个其他几个问题...

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

I think the problem is actually this line:

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

You can't use ENTITY and also an enumeration of possible values. (See here.)

You probably want:

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

There are also a couple of other issues...

  1. Your XML has multiple band child elements of bands, but the content model only allows one band. You probably want to add the + occurrence indicator:
<!ELEMENT bands (band+)>
  1. Your XML has multiple tune child elements of event, but the content model only allows one tune. You probably want to add the + occurrence indicator:
<!ELEMENT event (tune+)>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文