Reputation: 457
EDIT
I am having trouble implementing a DTD. I keep getting an error in my DTD saying:
"The markup in the document preceding the root element must be well-formed."
In my XML document I get the error:
"The markup declarations contained or pointed to by the document type declaration must be well-formed."
DTD
<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 06 07:25:48 AST 2014 -->
<!ELEMENT periodic-elements (periodic-element*)>
<!ELEMENT periodic-element (symbol, name, atomic-number, atomic_weight)>
<!ELEMENT symbol (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT atomic_number (#PCDATA)>
<!ELEMENT atomic_weight (#PCDATA)>
XML
<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 06 07:25:48 AST 2014 -->
<!DOCTYPE periodic SYSTEM "C:\Users\Randy\Desktop\CMIS 170\Week 3\Homework 3\Homework3DTD.txt">
<periodic>
<element>
<symbol>FE</symbol>
<name>Iron</name>
<atomic_number>26</atomic_number>
<atomic_weight>55.845</atomic_weight>
</element>
<element>
<symbol>Ir</symbol>
<name>Iridium</name>
<atomic_number>77</atomic_number>
<atomic_weight>192.217</atomic_weight>
</element>
<element>
<symbol>P</symbol>
<name>Phosphorus</name>
<atomic_number>15</atomic_number>
<atomic_weight>30.973762</atomic_weight>
</element>
<element>
<symbol>Uut</symbol>
<name>Ununtrium</name>
<atomic_number>113</atomic_number>
<atomic_weight>284</atomic_weight>
</element>
<element>
<symbol>Po</symbol>
<name>Polonium</name>
<atomic_number>84</atomic_number>
<atomic_weight>209</atomic_weight>
</element>
</periodic>
Any help would be appreciated.
Upvotes: 0
Views: 958
Reputation: 52888
You need to remove the DOCTYPE declaration from your DTD.
See External referenced DTD in XML for a better explanation.
You also need to change elements
to periodic
in the DOCTYPE declaration in your XML. The name in the DOCTYPE declaration must match the name of the root element.
Edit
The names in your DTD and your XML don't all match. For example, in your DTD you have periodic-elements
and periodic-element
, but your XML has periodic
and element
.
Also, your declaration for periodic-element
references the element atomic-number
, but your declaration is atomic_number
.
Here's a version that validates. You should be able to start with this and modify it however you like.
DTD
<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 06 07:25:48 AST 2014 -->
<!ELEMENT periodic-elements (periodic-element*)>
<!ELEMENT periodic-element (symbol, name, atomic_number, atomic_weight)>
<!ELEMENT symbol (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT atomic_number (#PCDATA)>
<!ELEMENT atomic_weight (#PCDATA)>
XML
<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 06 07:25:48 AST 2014 -->
<!DOCTYPE periodic-elements SYSTEM "C:\Users\Randy\Desktop\CMIS 170\Week 3\Homework 3\Homework3DTD.txt">
<periodic-elements>
<periodic-element>
<symbol>FE</symbol>
<name>Iron</name>
<atomic_number>26</atomic_number>
<atomic_weight>55.845</atomic_weight>
</periodic-element>
<periodic-element>
<symbol>Ir</symbol>
<name>Iridium</name>
<atomic_number>77</atomic_number>
<atomic_weight>192.217</atomic_weight>
</periodic-element>
<periodic-element>
<symbol>P</symbol>
<name>Phosphorus</name>
<atomic_number>15</atomic_number>
<atomic_weight>30.973762</atomic_weight>
</periodic-element>
<periodic-element>
<symbol>Uut</symbol>
<name>Ununtrium</name>
<atomic_number>113</atomic_number>
<atomic_weight>284</atomic_weight>
</periodic-element>
<periodic-element>
<symbol>Po</symbol>
<name>Polonium</name>
<atomic_number>84</atomic_number>
<atomic_weight>209</atomic_weight>
</periodic-element>
</periodic-elements>
Upvotes: 1