XML Development

Moderators: None (Apply to moderate this forum)
Number of threads: 252
Number of posts: 451

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
XML DTD Assistance Posted by DamienCurr on 23 Oct 2010 at 4:52 PM
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


<!--DVDs Private External DTD for Validating DVDs.xml-->
<?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 >




DVDs.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!-- DVDs.dtd can be found in the same directory as DVDs.xml -->
<!DOCTYPE DVDs SYSTEM "DVDS.dtd">
<DVDs>
<DVD>
<title>Star Wars Episode IV: A New Hope</title>
<genre>action</genre>
<movieRating>PG</movieRating>
<viewerRating>5</viewerRating>
<summary>Young hero Luke Skywalker joins the Rebel Alliance to help overthrow the tyrannical Galactic Empire.
</summary>
<year>1977</year>
<director>George Lucas</director>
<runtime>121</runtime>
<studio>20th Century Fox</studio>
<actors>
<actor idnum="0001">
<first>Mark</first>
<last>Hamill</last>
</actor>
<actor idnum="0002">
<first>Harrison</first>
<last>Ford</last>
</actor>
<actor idnum="0003">
<first>Carrie</first>
<last>Fisher</last>
</actor>
</actors>
</DVD>
<!-- Rest of DVDs omitted for brevity's sake -->
</DVDs>


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!
Report
Re: XML DTD Assistance Posted by alprog on 23 Oct 2010 at 11:32 PM
how to generate XML to another programming language ????



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.