Using the DTD validator here, I am informed that the following DTD is invalid.
在这里使用DTD验证器,我被告知以下DTD无效。
<!ENTITY % text "(#PCDATA|L)*">
<!ELEMENT H (%text;)+>
<!ELEMENT L (#PCDATA)>
The error message is: "A '(' character or an element type is required within declaration of element type "H"." at line 2, column 22.
错误消息是:“A'('字符或元素类型在元素类型”H“的声明中是必需的。”在第2行第22列。
Can anyone please point out why it is invalid? And how can I make it valid? The error message is not exactly very friendly to me. Thanks.
谁能指出为什么它无效?我怎样才能使它有效?错误消息对我来说并不是非常友好。谢谢。
1 个解决方案
#1
8
You cannot enforce that an element with mixed content must have at least one child node. Your DTD becomes
您无法强制具有混合内容的元素必须至少具有一个子节点。你的DTD变成了
<!ELEMENT H ((#PCDATA|L)*)+>
when the entity is expanded. The only allowed form for elements with mixed content is
当实体扩展时。具有混合内容的元素唯一允许的形式是
(#PCDATA | A | B | C)*
where A, B and C are possible child elements. #PCDATA
must be the first choice and the set must be allowed to repeat 0-infinity times, i.e. the asterisk is required.
其中A,B和C是可能的子元素。 #PCDATA必须是第一选择,并且必须允许该组重复0-infinity次,即需要星号。
#1
8
You cannot enforce that an element with mixed content must have at least one child node. Your DTD becomes
您无法强制具有混合内容的元素必须至少具有一个子节点。你的DTD变成了
<!ELEMENT H ((#PCDATA|L)*)+>
when the entity is expanded. The only allowed form for elements with mixed content is
当实体扩展时。具有混合内容的元素唯一允许的形式是
(#PCDATA | A | B | C)*
where A, B and C are possible child elements. #PCDATA
must be the first choice and the set must be allowed to repeat 0-infinity times, i.e. the asterisk is required.
其中A,B和C是可能的子元素。 #PCDATA必须是第一选择,并且必须允许该组重复0-infinity次,即需要星号。