Document Type Definition (DTD) in XML: Element type declaration, disadvantages

Document Type Definition (DTD): DTD is used for specifying structure of a document. It is used for declaring elements and attribute lists.

For Example:

<!ELEMENT employees (employeeNumber, employeeName, employeeSalary)>
<!ELEMENT employeeNumber (#PCDATA)>
<!ELEMENT employeeName (#PCDATA)>
<!ELEMENT employeeSalary (#PCDATA)>

Element type declaration: It is used to define elements and its contents. Element declarations can be of type:

1) Element only: Contents of this element are other elements. The element contained in this element type can be called as a sub element. By using this hierarchy of parent and child elements can be created. It can be used for representing a row of a table, with sub elements to represent the columns.

2) Text only: This element type has a text string. It can be used for representing data from a single column. It is indicated by keyword #PCDATA.

3) Mixed content: This type can contain text and sub elements.

4) Empty: This type doesn’t have any elements but it may have attributes. It can be used for representing row of a table when attributes are used for representing individual column values. It is indicated by keyword EMPTY.

5) Any content: This type can contain text, sub elements and empty element. It is indicated by using keyword ANY.

Disadvantages of DTD:

1) They do not specify a strong data type as used in relational database.

2) It does not support user defined types.

3) It doesn’t support sub document structures.

Leave a Reply