开发者

I can't understand how to use 'ANY' in Document Type Definition language

Suppose we have this XM开发者_开发知识库L document

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE note [

<!ELEMENT note (to,from,heading,body, foo)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ELEMENT foo ANY>

]>

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<foo><stuff>test</stuff></foo>
</note>

I'm using the ANY keyword for the element "foo" but I get an error saying

Line 20, Column 16: element "stuff" undefined

from this site http://validator.w3.org/check

why is this happening? isn't any supposed to accept any kind of parsable data in the foo element?


ANY means "Any element type defined in the DTD" not "Any element type the author cares to invent".

From the specification:

The declaration matches ANY, and the content (after replacing any entity references with their replacement text) consists of character data, CDATA sections, comments, PIs and child elements whose types have been declared.

(My emphasis)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜