ashamsuddin
03-12-2010, 03:39 AM
I'm taking an XML class and I'm working on my assignment. I've done everything the way my book says to but it's still not validating. Here's the xml code (the validator says that there's something wrong with my DTD statement. The basic structure of the xml has no errors):
<?xml version="1.0" encoding="utf-8"?>
<!-- Assignment 8
Adam Shamsuddin
CIS 072 Spring '10
-->
<!DOCTYPE animals SYSTEM "animals.dtd">
<animals>
<animal>
<name type="dog">Butch</name>
<breed>German Shepherd</breed>
<age>1</age>
<weight>45</weight>
<color>Brown</color>
<remarks>Good with children</remarks>
</animal>
<animal>
<name type="cat">Phoebe</name>
<breed>Mixed</breed>
<age>3</age>
<weight>15</weight>
<color>Tabby</color>
<remarks>Exellent mouser</remarks>
</animal>
<animal>
<name type="dog">Rex</name>
<breed>Mixed</breed>
<age>5</age>
<weight>20</weight>
<color>Brown</color>
<remarks>Needs lots of attention</remarks>
</animal>
<animal>
<name type="cat">Spooky</name>
<breed>Mixed</breed>
<age>.6</age>
<weight>10</weight>
<color>Black</color>
<remarks>Precious</remarks>
</animal>
<animal>
<name type="dog">Harry</name>
<breed>Chow Chow</breed>
<age>12</age>
<weight>64</weight>
<color>Cinnamon</color>
<remarks>Ann's very spoiled dog</remarks>
</animal>
</animals>
Now here's the code from an external DTD file called "animals.dtd". I don't see anything wrong, but you might:
<!ELEMENT animals (animal+)>
<!ELEMENT animal (name, breed, age, weight, color, remarks)>
<!ATTLIST name type (dog | cat)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT type (#PCDATA)>
<!ELEMENT breed (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT weight (#PCDATA)>
<!ELEMENT color (#PCDATA)>
<!ELEMENT remarks (#PCDATA)>
I would be very grateful for your help.
<?xml version="1.0" encoding="utf-8"?>
<!-- Assignment 8
Adam Shamsuddin
CIS 072 Spring '10
-->
<!DOCTYPE animals SYSTEM "animals.dtd">
<animals>
<animal>
<name type="dog">Butch</name>
<breed>German Shepherd</breed>
<age>1</age>
<weight>45</weight>
<color>Brown</color>
<remarks>Good with children</remarks>
</animal>
<animal>
<name type="cat">Phoebe</name>
<breed>Mixed</breed>
<age>3</age>
<weight>15</weight>
<color>Tabby</color>
<remarks>Exellent mouser</remarks>
</animal>
<animal>
<name type="dog">Rex</name>
<breed>Mixed</breed>
<age>5</age>
<weight>20</weight>
<color>Brown</color>
<remarks>Needs lots of attention</remarks>
</animal>
<animal>
<name type="cat">Spooky</name>
<breed>Mixed</breed>
<age>.6</age>
<weight>10</weight>
<color>Black</color>
<remarks>Precious</remarks>
</animal>
<animal>
<name type="dog">Harry</name>
<breed>Chow Chow</breed>
<age>12</age>
<weight>64</weight>
<color>Cinnamon</color>
<remarks>Ann's very spoiled dog</remarks>
</animal>
</animals>
Now here's the code from an external DTD file called "animals.dtd". I don't see anything wrong, but you might:
<!ELEMENT animals (animal+)>
<!ELEMENT animal (name, breed, age, weight, color, remarks)>
<!ATTLIST name type (dog | cat)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT type (#PCDATA)>
<!ELEMENT breed (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT weight (#PCDATA)>
<!ELEMENT color (#PCDATA)>
<!ELEMENT remarks (#PCDATA)>
I would be very grateful for your help.