我已经为下面的XML文件编写了以下DTD。在检查后它说它有效,但是,我有点担心,因为这是我的第一个DTD,我不确定它是否真的有效。 有人可以告诉我它是否正确? 谢谢!
DTD文件:
<?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文件:
<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>
答案 0 :(得分:1)
我检查了DTD和XML。对我来说看起来很好,至少在语法上。 (这是你问题的答案。)
几点提示: