Reputation: 1
I am in an XML class and my assignment is to create a family tree. I've pretty much finished the document and have been able to figure out and fix the errors displayed.
I am stuck on the current error "The content of element type "Child" must match "(firstName,middleName,surname,maidenName,suffix)". for lines 44,57 and 63. I guess I don't understand why I'm getting the error; it looks to me like I've done things correctly.
Here is what I have:
<?xml version="1.0"?>
<!DOCTYPE Family [
<!ELEMENT Family (Father, Mother, Offspring)>
<!ELEMENT Father (firstName, middleName, surname)>
<!ELEMENT firstName (#PCDATA)>
<!ELEMENT middleName (#PCDATA)>
<!ELEMENT surname (#PCDATA)>
<!ELEMENT Mother (firstName, middleName, surname, maidenName)>
<!ELEMENT maidenName (#PCDATA)>
<!ELEMENT Offspring (Child)>
<!ELEMENT Child (firstName, middleName, surname, maidenName, suffix)>
<!ATTLIST Child
ID CDATA #REQUIRED
gender (Male | Female) "Female"
birthPlace CDATA #IMPLIED
birthYear CDATA #IMPLIED>
<!ELEMENT suffix (#PCDATA)>
]>
<Family>
<Father>
<firstName>William</firstName>
<middleName>Fitzgerald</middleName>
<surname>Buckley</surname>
</Father>
<Mother>
<firstName>Ella</firstName>
<middleName>Ann</middleName>
<surname>Buckley</surname>
<maidenName>Fitzgerald</maidenName>
</Mother>
<Offspring>
<Child ID="01" gender="Male">
<firstName>Gordon</firstName>
<middleName>Shumway</middleName>
<surname>Buckley</surname>
<suffix></suffix>
</Child>
<Child ID="02">
<firstName>Alice</firstName>
<middleName>Mae</middleName>
<surname>Nelson</surname>
<maidenName>Buckley</maidenName>
<suffix></suffix>
</Child>
<Child ID="03" gender="Male">
<firstName>Julius</firstName>
<middleName>Caesar</middleName>
<surname>Buckley</surname>
<suffix></suffix>
</Child>
<Child ID="04" gender="Male">
<firstName>Martin</firstName>
<middleName>Lawrence</middleName>
<surname>Buckley</surname>
<suffix></suffix>
</Child>
</Offspring>
</Family>
Thank you in advance for the assistance!
Kris
Upvotes: 0
Views: 71
Reputation: 134611
The DTD states that all Child
elements requires a firstName
, middleName
, surname
, maidenName
, and suffix
.
<!ELEMENT Child (firstName, middleName, surname, maidenName, suffix)>
However you have a couple of Child
elements that does not have a maidenName
.
<Child ID="01" gender="Male">
<firstName>Gordon</firstName>
<middleName>Shumway</middleName>
<surname>Buckley</surname>
<suffix></suffix>
</Child>
<Child ID="03" gender="Male">
<firstName>Julius</firstName>
<middleName>Caesar</middleName>
<surname>Buckley</surname>
<suffix></suffix>
</Child>
<Child ID="04" gender="Male">
<firstName>Martin</firstName>
<middleName>Lawrence</middleName>
<surname>Buckley</surname>
<suffix></suffix>
</Child>
Did you mean to make the maidenName
optional?
<!ELEMENT Child (firstName, middleName, surname, maidenName?, suffix)>
Upvotes: 1
Reputation: 14685
You said this:
<!ELEMENT Child (firstName, middleName, surname, maidenName, suffix)>
But later you said this:
<Child ID="01" gender="Male">
<firstName>Gordon</firstName>
<middleName>Shumway</middleName>
<surname>Buckley</surname>
<suffix></suffix>
</Child>
This Child does not have a maidenName, which you said it has to have.
Try putting
<maidenName></maidenName>
in the Child, as you have done with suffix... depending on the application that is parsing this, that might work.
Upvotes: 0