Creating a Valid Document from a DTD

The next chapter covers some additional DTD constructs, such as entities and notations. Now is a good time to take a look at how to create a document based on a DTD. Listing 3.2 contains the complete code for the movie collection DTD that you've learned about throughout the chapter, which is stored in the file Movies.dtd.

Listing 3.2. The Movie Collection DTD, Complete with Elements and Attributes
 <!ELEMENT movies (movie)+> <!ELEMENT movie (title, writer+, producer+, director+, actor*, comments?)> <!ATTLIST movie type (drama | comedy | adventure | sci-fi | mystery | horror | romance | documentary) "drama" rating (G | PG | PG-13 | R | X) "PG" review (1 | 2 | 3 | 4 | 5) "3" year CDATA #IMPLIED> <!ELEMENT ...

Get XML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.