What is DTD?

XML Document Type Declaration, commonly known as DTD, is a way to describe precisely the XML language. DTDs check the validity of structure and vocabulary of an XML document against the grammatical rules of the appropriate XML language.
An XML document 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.
  • 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 diagram represents that a DTD is used to structure the XML document:


DTD can be classified on its declaration basis 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.
Continue Reading – Tutorials Point

Leave a Reply

Your email address will not be published. Required fields are marked *