A Valid XML Example: Constructing the DTD

Now that we have seen all the components that can be used to construct a DTD, let's take a look at an example from scratch.

In this example, we're going to create a simple DTD for use with a newspaper. Our newspaper is going to contain information about the edition, such as the paper name, the publisher, and some copyright information. Then, the newspaper will contain sections, a minimum of one, which will in turn contain articles and ads.

Each article must contain a headline and a body, and may additionally contain a subhead, a lead, and some notes. Each article must also have an attribute for the author, and may have attributes for the editor, the date, and the edition.

Each ad will contain the ad copy, ...

Get Special Edition Using XML, Second Edition 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.