# Editing DTDs

You can edit DTD files in both the Outline view and the Source view. Modifying the content of a DTD determines what can be used in any XML file that is associated with it.

You can edit DTDs in the following ways:

- Create or remove elements, attributes, entities, notations, and comments
- Edit an element's content model
- Edit a group
- Reuse entities

Editing in the Outline view

The Outline view will show you all the items in your DTD as you add them. In this view, you can both create and delete DTD nodes.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives. To edit a DTD in the Outline view, follow these steps:

1. Create a new DTD or double-click an existing DTD in the Navigator view. It will automatically open in the DTD editor.
2. In the Outline view, right-click the DTD and select the node you want to add to it.
3. In the Properties view, edit the fields for the node as appropriate.

The DTD editor has a built-in mechanism to handle referential integrity issues. When you delete or edit certain components, clean up will automatically occur. Refer to the related reference section for more information.

Editing in the Source view

You can edit the source code for your DTD in the Source view manually.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives. To edit a DTD in the Source view, follow these steps:

1. Create a new DTD or double-click an existing DTD in the Navigator view. It will automatically open in the DTD editor.
2. Select the source code you want to edit - you can edit existing nodes or create new ones.
3. Your changes to the DTD will automatically be reflected in the Outline and Properties views. If you have created any errors in your code while editing in the Source view, they will appear in the Problems view when you save or validate the file.
4. The DTD editor has a built-in mechanism to handle referential integrity issues, however, this mechanism only works if you delete items using the Outline view or edit them in the Properties view. If you delete or edit items using the Source view, clean up will not automatically occur; instead you will receive error messages in the Problems view if you validate or save the file.

Sorting nodes in the Outline view

By default, DTD nodes appear in the Outline view in the order you added them to the DTD.

If you want to sort the DTD nodes alphabetically, click the Sort items alphabetically button .

You can also group the DTD nodes into logical groups - notations, entities, elements, and other. Click the Group items logically button to sort the DTD nodes into logical groups.

The following links contain information on how you can edit DTD files:

> Creating elements
> You can use element declarations in DTDs to define the elements that may occur in an XML document. Element declarations can specify that an element can contain other elements, that it can contain anything at all, or that it must be empty.
> Creating entities
> An entity is a shortcut used to represent complex strings or symbols that would otherwise be impossible, difficult or repetitive to include by hand.
> Creating notations
> Notations are means of associating a binary description with an entity or attribute. The most common uses of notations are to include familiar types of binary references, such as GIFs and JPGs, in an XML file.
> Creating a comment
> Comments can be used to provide information about a document, such as the author's name, or the date it was last modified. Comments are visible to anyone reading the DTD, but are ignored by the XML parser.
> Deleting elements, attributes, entities, notations, and comments
> If you have created elements, attributes, entities, notations, and comments you no longer need, you can delete any of them.

Related concepts
DTD editor
Document type definitions (DTDs) - overview

Related tasks
Creating DTDs
Importing DTDs

Related reference
Referential integrity in the DTD editor

(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.