What is DTD?

Home » Blog » Internet » What is DTD?

Stands for “Document Type Definition.” A defines the and attributes used in an  or  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 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 (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 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.

Leave a Comment

%d bloggers like this:
Read previous post:
What is XHTML?

Stands for "Extensible Hypertext Markup Language." XHTML is markup language used to create webpages. It is similar to HTML but uses a more strict XML-based syntax....

Close