XML DTD Assistance

Good evening!

I am working on an assignment where I create DVD database in XML and validate it with a DTD. I believe that I have accomplished this, but I would like someone to look at it and tell me if you see any issues. So far, everything validates fine, in other words no errors when displayed in an Internet Explorer window. However, I would like to make sure that I am hitting the right points.

DVDs.dtd file

[code]


<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT DVDs (DVD)+>

<!ELEMENT DVD (title, genre, movieRating, viewerRating, summary, year, director, runtime, studio, actors)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT genre (#PCDATA)>
<!ATTLIST genre kind (action | comedy | drama | family | foreign | horror | musical | other) #REQUIRED >

<!ELEMENT movieRating (#PCDATA)>
<!ATTLIST movieRating rating (G | PG | PG-13 | R | NC-17) #REQUIRED >

<!ELEMENT viewerRating (#PCDATA)>
<!ATTLIST viewerRating rating (1 | 2 | 3 | 4 | 5) #REQUIRED >

<!ELEMENT summary (#PCDATA)>

<!ELEMENT year (#PCDATA)>

<!ELEMENT director (#PCDATA)>

<!ELEMENT runtime (#PCDATA)>

<!ELEMENT studio (#PCDATA)>

<!ELEMENT actors (actor)+>
<!ELEMENT actor (first, last)>
<!ELEMENT actor (#PCDATA)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ATTLIST actor idnum CDATA #REQUIRED >


[/code]

DVDs.xml

[code]

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE DVDs SYSTEM "DVDS.dtd">


Star Wars Episode IV: A New Hope
action
PG
5
Young hero Luke Skywalker joins the Rebel Alliance to help overthrow the tyrannical Galactic Empire.

1977
George Lucas
121
20th Century Fox


Mark
Hamill


Harrison
Ford


Carrie
Fisher





[/code]

Main points that I am concerned about:

1) 'movieRatings' should only be one of the choices in the enumerated list (G, PG, etc.). When I tried to enter a different value in the xml file, it still validated in the Internet Explorer window (i.e. no errors). I thought it would fly unless it was one of the predetermined choices?

2) Although it does not specify in the assignment description, I would like to do something similar with 'viewerRating'. In other words, only a number of 1 to 5 may be entered.

3) Each actor has to have their first and last name listed and is to have a unique identifier. I think I did it right but would like to be sure.

Any and all suggestions, comments or observations are welcome. Thanks in advance!

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion