PC.net
HomeHome : Glossary : Definition
ShareShare

DTD

DTD Image

Stands for "Document Type Definition." A DTD defines the tags and attributes used in an XML or HTML document. Any elements defined in a DTD can be used in these documents, along with the predefined tags and attributes that are part of each markup language. The following is an example of a DTD used for defining an automobile:

<!DOCTYPE automobile [
   <!ENTITY header "Car Details">
   <!ELEMENT make (#PCDATA)>
   <!ELEMENT model (#PCDATA)>
   <!ATTLIST model doors (two | four) #required>
   <!ELEMENT year (#PCDATA)>
   <!ELEMENT engine (#PCDATA)>
   <!ATTLIST engine transmission (manual | automatic) #required>
]>

The above DTD first defines the header of the item as "Car Details." Then it provides elements to define the make and model of the automobile. The "#PCDATA" data type means it can be any text value). The "ATTLIST" tag on the next line provides options for a specific element. In this case, it states that the model can have either two or four doors. The DTD then provides elements for the year and engine type of the car, followed by a choice of either a manual or automatic transmission for the engine.

The above example is a basic DTD that only uses a few data types. Document type definitions used for large XML databases can be thousands of lines long and can include many other data types. Fortunately, DTDs can be easily modified in a text editor whenever changes need to be made.

Published: 2005

Definition from the PC Glossary
https://pc.net/glossary/dtd
space