Reputation: 11
I've written the following DTDs for the XML file below. After checking it says it's valid, however, I'm a bit concerned since this is my very first DTD and I'm not sure if it's actually valid or not. Can someone tell me if it's correct? Thanks!
DTD file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE articles [
<!ELEMENT articles (article+)>
<!ELEMENT article (authors+,journal+)>
<!ELEMENT authors (author+)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT journal (name+, volume?,issue?,published+,url?,pages?)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT issue (#PCDATA)>
<!ELEMENT published (#PCDATA)>
<!ELEMENT volume (#PCDATA)>
<!ELEMENT pages (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ATTLIST article title CDATA #REQUIRED id ID #REQUIRED>
<!ATTLIST pages start CDATA #REQUIRED end CDATA #REQUIRED>
<!ATTLIST url href CDATA #REQUIRED>
]>
XML File:
<articles>
<article title="Computing" id="a1">
<authors>
<author>Fhilbertie</author>
<author>Alicen</author>
<author>PeDra</author>
</authors>
<journal>
<name>Journals</name>
<volume>5</volume>
<issue>6</issue>
<published>06/11/2013</published>
<pages start="52" end="79"/>
</journal>
</article>
<article title="Instruction Sets: Free Will?" id="a2">
<authors>
<author>Sallie</author>
<author>Philber</author>
</authors>
<journal>
<name>Metaphysics</name>
<volume>5</volume>
<issue>6</issue>
<published>06/26/2015</published>
<pages start="366" end="366"/>
</journal>
</article>
<article title="My Journy" id="a3">
<authors>
<author>Lawrence</author>
</authors>
<journal>
<name>M Magic</name>
<volume>6</volume>
<issue>4</issue>
<published>11/12/1988</published>
</journal>
</article>
<article title="RDF Triples and the Path to Human Subjugation" id="a4">
<authors>
<author>Allison Peony</author>
<author>Robert Zephyr</author>
<author>Sally Piper</author>
</authors>
<journal>
<name>Journal of Nefarious Artificial Intelligence</name>
<published>05/25/2006</published>
<url href="http://example.com/rdf-triples-subjugation"/>
</journal>
</article>
<article title="Marksideways, a Markdown Alternative" id="a5">
<authors>
<author>Gerald Quinoa</author>
<author>P. von Cookie</author>
</authors>
<journal>
<name>Marvelous Markup Magic</name>
<volume>13</volume>
<issue>3</issue>
<published>03/14/2013</published>
<url href="http://example.com/marksidways"/>
</journal>
</article>
<article title="Hills" id="a6">
<authors>
<author>Robert Z</author>
<author>Leonard P</author>
</authors>
<journal>
<name>Journal Intelligence</name>
<published>05/25/2014</published>
<url href="http://example.com/hill"/>
</journal>
</article>
Upvotes: 1
Views: 135
Reputation: 43709
I've checked the DTD and the XML. Looks quite fine for me, at least syntactically. (This is the answer to your question.)
Few hints:
Upvotes: 1