Reputation: 123
I ran my XML/DTD through w3schools validator it tells me it has allot of errors, what am I doing wrong? I will admit it's been a few years since I used XML
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<!DOCTYPE WEBDESIGNTOPICS [
<!ELEMENT WEBDESIGNTOPICS (topic+,topicname+,description+,provided)>
<!ELEMENT topic (#PCDATA)>
<!ELEMENT topicname (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT provided (#PCDATA)>
]>
<WEBDESIGNTOPICS>
<topic>
<topicname>HTML5</topicname>
<description>HAMILTON</description>
<provided>SALESMAN</provided>
</topic>
<topic>
<topicname>CSS/CSS3</topicname>
<description>SMITH</description>
<provided>CLEANER</provided>
</topic>
<topic>
<topicname>PHP</topicname>
<description>JONES</description>
<provided>MANAGER</provided>
</topic>
<topic>
<topicname>JavaScript</topicname>
<description>JONES</description>
<provided>MANAGER</provided>
</topic>
<topic>
<topicname>jQuery</topicname>
<description>JONES</description>
<provided>MANAGER</provided>
</topic>
</WEBDESIGNTOPICS>
Upvotes: 1
Views: 643
Reputation: 111491
Note that your XML document is well-formed but is not valid. You can read about the difference between well-formed and invalid here.
To make your XML be valid:
Change the content model of WEBDESIGNTOPICS
to reflect the fact
that it's clearly just a list of topics
:
<!ELEMENT WEBDESIGNTOPICS (topic+)>
Change the content model of topic to reflect that it can consist of
a topicname
, description
, and provided
element or elements.
You have to decide on the requiredness and cardinality as the sample
XML cannot indicate generality itself:
<!ELEMENT topic (topicname,description,provided)>
Altogether then, this updated XML document will be valid:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<!DOCTYPE WEBDESIGNTOPICS [
<!ELEMENT WEBDESIGNTOPICS (topic+)>
<!ELEMENT topic (topicname,description,provided)>
<!ELEMENT topicname (#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT provided (#PCDATA)>
]>
<WEBDESIGNTOPICS>
<topic>
<topicname>HTML5</topicname>
<description>HAMILTON</description>
<provided>SALESMAN</provided>
</topic>
<topic>
<topicname>CSS/CSS3</topicname>
<description>SMITH</description>
<provided>CLEANER</provided>
</topic>
<topic>
<topicname>PHP</topicname>
<description>JONES</description>
<provided>MANAGER</provided>
</topic>
<topic>
<topicname>JavaScript</topicname>
<description>JONES</description>
<provided>MANAGER</provided>
</topic>
<topic>
<topicname>jQuery</topicname>
<description>JONES</description>
<provided>MANAGER</provided>
</topic>
</WEBDESIGNTOPICS>
Upvotes: 1