O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required