Question

Suppose we have this XML 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?

Was it helpful?

Solution

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)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top