Creating a Document Type Definition (DTD)

XML is remarkably flexible. If you don't use a DTD, you can create a document using almost any kind of structure you want. You might choose to represent a person's name through attributes:

<person first-name="Samantha" last-name="Tippin">

Or, you might create separate tags for the various data items associated with a person:

<person>
    <first-name>Samantha</first-name>
    <last-name>Tippin</last-name>
</person>

Flexibility, of course, is a two-edged sword. Because you are able to format your data how ever you like, it's unlikely you'll use the same format as someone else. A Document Type Definition enables you to define a specific format for an XML document. You can specify which tags might appear in a ...

Get Special Edition Using Java™ 2 Enterprise 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.