Forum Moderators: open

Message Too Old, No Replies

Desiging a DTD

Desiging a DTD

         

MrMojoRisin

3:27 am on Feb 20, 2007 (gmt 0)

10+ Year Member



Hello, I have this question for an assignment for a Java class. Our textbook is very brief in both content and examples. Therefore I am wondering if I wrote a valid DTD for the following question.

Design a DTD that describes a library patron who has checked out a set of books. Each book has an ID number, an author, and a title. The patron has a name and telephone number.

Looking at the textbook and at other books and sources, I think this is right, though I am not sure.

<!ELEMENT library-patron (set-of-books, name, telephone-number)>
<!ELEMENT set-of-books (book+)>
<!ELEMENT book (ID-Number, author, title)>
<!ELEMENT ID-Number (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT telephone-number (#PCDATA)>

I figure the XML for this would be something like this:

<?xml version="1.0" encoding="iso-8859-1"?>
<library-patron>
<set-of-books>
<book>
<ID-Number>56564</ID-Number>
<author>Charles Dickens</author>
<title>A Tale of Two Cities</title>
</book>
<book>
<ID-Number>56564</ID-Number>
<author>Charles Dickens</author>
<title>A Tale of Two Cities</title>
</book>
<book>
<ID-Number>56564</ID-Number>
<author>Charles Dickens</author>
<title>A Tale of Two Cities</title>
</book>
</set-of-books>
<name>John Smith</name>
<telephone-number>212-555-6565</telephone-number>
</library-patron>

Am I correct? Thanks