DTD没有很好地形成

时间:2014-10-02 01:22:49

标签: xml dtd

有人可以指出我错在哪里......这真的让我陷入困境吗?!?!?!

为某些XML编码编写DTD ...我在解析XML时不断收到错误

ret.dtd:2:文档类型声明包含或指向的标记声明必须格式正确。

我会发布一些代码,希望它足以让某人提供帮助

<!DOCTYPE ret [
<!-- 
1.      The element ret
1.1.    The element ret has an attribute version that must have the value 1.0
1.2.    The element ret has a required attribute date that has a text representing the date of feed.
1.3.    The element ret can have 0 or more feed elements 
1.4.    The element ret's last element is a required doc-copyright element.  The copyright statement for your company. -->

<!ELEMENT ret (feed)*>
<!ATTLIST ret version CDATA #FIXED "1.0">
<!ATTLIST ret date CDATA #REQUIRED >

<!--
2.  The element feed
2.1.    The element feed starts with a required source element.  Must appear exactly once. The source of the feed
2.2.    The element feed's second element feed-desc is optional, but if present, appears no more than once.  This is a description of the feed and its source.
2.3.    The element feed's third element info is optional, but if present, appears no more than once.  This is additional information about the feed.
2.4.    The element feed's last element is a required stories element. Must appear exactly once. A list of feed stories. -->

这是我的DTD的开始......我错过了什么?

1 个答案:

答案 0 :(得分:2)

在内容模型之外使用星号时应该没有问题。模型(feed)*应该没问题。 (用Xerces或W3C Markup Validation Service进行验证很好。)

基于错误中的文件名“ret.dtd”,看起来您正在使用外部DTD。外部DTD中不应包含DOCTYPE声明。 DOCTYPE声明应该在XML实例中。尝试从DTD中删除<!DOCTYPE ret [(和]>)。

这是另一个有同样错误的问题,并通过删除重复的DOCTYPE声明解决:External referenced DTD in XML