xml dtd
XML

XML DTD Tutorial

What is dtd in xml ?

In xml dtd stands for Document Type Definition. XML dtd is used to express the XML language. XML dtd is generally usd for the following purpose.
  • DTD in XML is used to check the validity of XML.
  • Structure and vocabulary of XML can be checked using xml dtd.
  • XML dtd Checks the grammatical rules of XML language.
DTD contains declaration of following XML components
  • Element
  • Attributes
  • Entities
Elements are building block of XML document.
 
Attributes are associated with elements describe its features.
Entities are placeholders in XML which can be declared in the document

xml dtd

Features of xml dtd

Various features of xml dtd are as follow
  • DTD decides the elements which appears in DTD
  • Xml dtd decides the order of appeared elements
  • DTD decides the elements are optional or mandatory

Advantages of xml dtd

Various advantages of using the xml dtd are as follow-
  • Validity checking : It checks the validity of XML file by checking the order of elements and the elements are inserted in correct way.
  • Documentation : One of the major advantage is that you can define your own XML format . various Users can understand the structure by looking over the Document defined

Disadvantages of using the xml dtd

Some disadvantages of using xml dtd are as follow-
  • Text strings data types are supported only.
  • Object – oriented feature is not there in DTD.
  • Namespaces are not supported.

XML dtd syntax

Basic Syntax of declaring the xml document is as follow
 
Where
  • DTD starts with declaration DOCTYPE
  • DTD Identifier is used for document type declaration , a DTD can have External Subset also.
  • Various declarations are enclosed in Square Brackets called Internal Subset.
For Internal and External DTD , you have different syntax structure which is explained in next section of this xml dtd tutorial.

Types of xml dtd

Different types of dtd in xml are explained in this section. These types of xml dtd are as follow:-
DTD can be classified on the basis of declaration of XML document  in two ways-

(1) Internal DTD

 If elements of dtd are declared inside the xml file then this type of dtd is referred as internal dtd.
Syntax for Internal dtd in xml.
 
Syntax for internal dtd is as follow

 

 
Where root is the root element of the document and declaration is where you declare the elements.
Example
 
 An example of xml dtd example for internal dtd is as shown in following figure.
 
 
xml dtd example pdf
 
 

(2) External DTD

When dtd elements are declared in external file and this file must be accessed in main XML document in which we are using this dtd. The definition in xml document must contain a reference to this external DTD file.
Syntax for using accessing the external dtd in xml file is as follow
 
 
 
Where file name defines with .dtd extension.

Example for external dtd

An example for xml dtd is given below.
 
structure of dtd
 

Conclusion

In this tutorial we discussed about xml document type definition it means xml dtd. We learned about different features of xml dtd, use of xml dtd, its advantages and disadvantages, syntax of xml dtd, how to use internal dtd and external dtd.
 
I hope this xml dtd tutorial will be helpful to you in understanding the concepts and use of xml dtd.
 
 
 
 
.
 

Leave a Reply

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