Link to home
Start Free TrialLog in
Avatar of cookiejar
cookiejarFlag for United States of America

asked on

DTD - how to define attritbutes and two child elements

I have an XML file with two child elements to the root but I am getting a null error for the second child element.  It is also expecting definition for the attributes, could you show how this is done?

Thank you.  See the attachments.
contacts.txt
contacts.xml
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

I used this tool http://www.xmlvalidation.com/
with your input files.

It reported these errors.
Attribute "favcolor" must be declared for element type "family".
Attribute "gender" must be declared for element type "family".
Element type "friend" must be declared.
<!ELEMENT contacts (family|friend)+>
<!ELEMENT friend (name,address,city,state,zip_code,phone,birthday?)>
<!ELEMENT family (name,address,city,state,zip_code,phone,birthday?)>
<!ATTLIST friend
gender CDATA #IMPLIED
favcolor CDATA #IMPLIED 
>
<!ATTLIST family
gender CDATA #IMPLIED
favcolor CDATA #IMPLIED 
>
<!ELEMENT name (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT zip_code (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT birthday (#PCDATA)>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You say this is an assignment, but you are obviously missing the basics.
Please read the course material before jumping right in the task,
it would help you understand what is going on

or start here
http://www.w3schools.com/dtd/default.asp
it is not a good tutorial, but it gives you some syntax basics