A DTD document can be edited in Text View and Grid View. The default view can be set in the File Types section of the Options dialog.
In Text View, the document is displayed with syntax coloring and must be typed in. Given below is a sample of a DTD fragment:
<!-- Element declarations -->
<!ELEMENT document (header, para, img, link)>
<!ELEMENT header (#PCDATA)>
<!ELEMENT img EMPTY>
src CDATA #REQUIRED
<!-- Notation Declarations -->
<!NOTATION GIF PUBLIC "urn:mime:img/gif">
Indentation is indicated by indentation guides and is best obtained by using the tab key. The amount of tab indentation can be set in the Text View Settings dialog.
In Grid View, the DTD document is displayed as a table. The screenshot below shows the Grid View display of the DTD listed above.
When the cursor is inside a row of the table, or if a row is selected, DTD editing commands in the XML menu become enabled. You can insert, append, and add child nodes to the graphical representation of the DTD. The DTD items available at a particular selection point are enabled in the respective sub-menu of the XML menu (Insert, Append, Add Child). You can also convert a selected DTD item to another item, and move the item left or right in order to change its position in the document hierarchy. When a node is selected, available DTD items are also displayed as items in the entry helpers.
XMLSpy offers the following very useful features:
•Convert DTD to XML Schema: With the DTD/Schema | Convert DTD to Schema command, DTDs can be converted to XML Schemas.
•Generate sample XML file from DTD: With the DTD/Schema | Generate Sample XML/JSON File command, an XML document can be generated that is based on the active DTD.