...

View Full Version : Why is this not valid ?



brothercake
11-29-2002, 03:27 PM
Here's an excerpt from the DTD



<!DOCTYPE kar_trends [

<!ELEMENT kar_trends (subject)*>
<!ELEMENT subject (about,study)>
<!ELEMENT about (#PCDATA)>
<!ELEMENT study (#PCDATA)>

<!ENTITY coi "Captains of Industry">

<!ATTLIST study year CDATA #REQUIRED>
<!ATTLIST study season CDATA #REQUIRED>

]>



And here's a sample of the XML



<kar_trends>

<subject>
<about>3com</about>
<study year="1998" season="w">&coi;</study>
</subject>

</kar_trends>



But when I validate it I get any error message, that the STUDY element has invalid content. Huh??

mpjbrennan
11-29-2002, 03:40 PM
what happens if you put #&coi; ?

patrick

brothercake
11-29-2002, 04:02 PM
same thing - invalid element content

brothercake
11-29-2002, 05:30 PM
I found it! I was assuming, since the error pointed the line with that entity on it, that the entity was the issue. But no. In fact it was my fault - the DTD specifies only a single instance of <study> in each <subject>. It should have been:



<!ELEMENT subject (about,study+)>



I should have posted a more complete code sample - the sample I posted actually is valid by that DTD, but what I'm actually using, which produced the error, is like this:



<subject>
<about>3com</about>
<study year="1998" season="w">&coi;</study>
<study year="1999" season="w">&coi;</study>
<study year="2000" season="w">&coi;</study>
<study year="2000" season="w">&itp;</study>
</subject>


doh :rolleyes: thanks for the help though



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum