문제

Using the DTD validator here, I am informed that the following DTD is invalid.

<!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.

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.

도움이 되었습니까?

해결책

You cannot enforce that an element with mixed content must have at least one child node. Your DTD becomes

<!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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top