Creating DTDs

A document type definition contains a set of rules that can be used to validate an XML file. After you have created a DTD, you can edit it, adding declarations that define elements, attributes, entities and notations for any XML files that reference the DTD file. You can also establish constraints for how each element, attribute, entity and notation may be used within any XML files that reference the DTD file.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

Follow these steps to create a new DTD:

  1. If necessary, create a project to contain the DTD.

  2. In the workbench, select...

    File | New | Other | XML | DTD Next

    If you cannot see the XML option, select the Show All Wizards check box.

  3. Select the project or folder that will contain the DTD.

  4. In the File name field, type the name of the DTD, for example MyDTD.dtd. The name of the DTD file must end with the extension .dtd

  5. Click Finish.

The DTD appears in the Navigator view and automatically, by default, opens in the DTD editor. In the DTD editor, you can add elements, attributes, notations, entities, and comments to the DTD. If you close the DTD editor, and want to later re-open the file in it, double-click the file in the Navigator view.

Document type definition (DTD) - overview
A document type definition (DTD) provides you with the means to validate XML files against a set of rules. When you create a DTD file, you can specify rules that control the structure of any XML files that reference the DTD file. A DTD can contain declarations that define elements, attributes, notations and entities for any XML files that reference the DTD file. It also establishes constraints for how each element, attribute, notation, and entity may be used within any of the XML files that reference the DTD file.

 

Related concepts

DTD editor

 

Related tasks

Editing DTDs
Generating an XML schema from a DTD file