Editing DTDs
Once you have created a DTD, you can edit it in the DTD editor. You can also import DTDs you have created outside the product and edit them in the DTD editor.
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
Edit in the Outline view
The Outline view will show you all the items in the 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,...
- Create a new DTD or double-click an existing DTD in the Navigator view. It will automatically open in the DTD editor.
- In the Outline view, right-click the DTD and select the node you want to add to it.
- 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 below for more information.
Sort 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, attributes, comments, and "other". The "other" group will contain anything that does not fall into the other groups. Click the Group items logically button to sort the DTD nodes into logical groups.
Editing in the Source view
You can edit the source code 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:
- Create a new DTD or double-click an existing DTD in the Navigator view. It will automatically open in the DTD editor.
- Select the source code you want to edit - you can edit existing nodes or create new ones.
- Your changes to the DTD will automatically be reflected in the Outline and Properties views. If you have created any errors in the code while editing in the Source view, they will appear in the Problems view when you save or validate the file.
- 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.
DTD editor
You can use the Create a DTD wizard ( File > New > Other > XML > DTD) to create new DTD. As well, you can also import DTDs from outside the product.Creating elements
In the DTD editor, you can create an element type declaration. This is a syntax for formally describing what an element type is and what type of data it can contain. Its basic format is: <!ELEMENT name (content-model)> , where name is the element-type and (content-model) is the type of data the element can contain.:Creating entities
You can add entities to a DTD file. An entity is a shortcut used to represent complex strings or symbols that would otherwise be impossible, difficult or repetitive to include by hand. For example: You need to place a copyright notification (for example, Copyright 2004. MyCompany publishing.) at the end of every page of a book. Instead of writing it every time, you could create an entity that represents this text: <!ENTITY copyright "Copyright 2004. MyCompany publishing."> where copyright is the name of the entity and "Copyright 2004. MyCompany publishing" is the text that the copyright entity represents.Creating notations
You can add notations to the DTD file. Notations are means of associating a binary description with an entity or attribute. For example: You are making a catalogue of the clothing and want to include an image of one of the shirts. You would have to create a notation such as the following :<!NOTATION myshirt SYSTEM "GIF"> which defines a notation for a GIF image.Creating a comment
You can add a comment to a DTD file, which is a note that is visible to the DTD's author, but is ignored by the XML parser.Deleting elements, attributes, entities, notations, and comments
In the DTD editor, you can create and edit elements, attributes, entities, notations and comments. You can also delete any of these after you have created them.
Related concepts
DTD editor
Related tasks
Creating DTDs
Importing DTDs