DTD Overview - Document Type Definition (DTD)

What is DTD Overview?

XML Document Type Declaration, normally identified as DTD, is a way to explain correctly the XML language. DTDs check the strength of structure and vocabulary of an XML document beside the grammatical rules of the suitable XML language.

An XML manuscript can be defined as:

  • Well-formed: If the XML document adheres to all the general XML rules such as tags must be properly nested, opening and closing tags must be balanced, and empty tags must end with '/>', then it is called as well-formed.

OR

  • Valid: An XML document said to be valid when it is not only well-formed, but it also conforms to available DTD that specifies which tags it uses, what attributes those tags can contain, and which tags can occur inside other tags, among other properties.

The following illustration represent that a DTD is used to constitution the XML document:
dtd_technology

Types

DTD can be classifying on its declaration foundation in the XML document, such as:

  • Internal DTD
  • External DTD

When a DTD is declared within the file it is called Internal DTD and if it is declared in a separate file it is called External DTD.

We will learn more about these in the chapter DTD Syntax

Features

Following are some important points that a DTD describes:

  • The elements that can appear in an XML document.
  • The order in which they can appear.
  • Optional and mandatory elements.
  • Element attributes and whether they are optional or mandatory.
  • Whether attributes can have default values.

Advantages of using DTD

  • Documentation - You can describe your own format for the XML files. Looking at this document a user/developer can realize the structure of the data.
  • Validation - It gives a way to check the strength of XML files by checking whether the rudiments appear in the right order, mandatory basics and attributes are in place, the elements and attributes have not been inserted in an incorrect way, and so on.

Disadvantages of using DTD

  • It does not maintain the namespaces. Namespace is a mechanism by which element and characteristic names can be assigned to groups. However, in a DTD namespaces have to be defined within the DTD, which violates the purpose of using namespaces.
  • It supports only the text string data type.
  • It is not object oriented. Hence, the model of inheritance cannot be apply on the DTDs.
  • Partial possibilities to express the cardinality for fundamentals.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Document Type Definition (DTD) Topics