Open In App

Difference between Document Type Definition (DTD) and XML Schema Definition (XSD)

Improve
Improve
Like Article
Like
Save
Share
Report

Document Type Definition (DTD) 

DTD stands for Document Type Definition and it is a document which defines the structure of an XML document. It is used to describe the attributes of XML language precisely. It can be classified into two types namely internal DTD and external DTD. It can be specified inside a document or outside a document. DTD mainly checks the grammar and validity of a XML document. It checks that a XML document has a valid structure or not. 

XML Schema Definition (XSD)

XSD stands for XML Schema Definition and it is a way to describe the structure of a XML document. It defines the rules for all the attributes and elements in a XML document. It can also be used to generate the XML documents. It also checks the vocabulary of the document. It doesn’t require processing by a parser. XSD checks for the correctness of the structure of the XML file. XSD was first published in 2001 and after that it was published in 2004. 

Difference between Document Type Definition (DTD) and XML Schema Definition (XSD) 

S.NO. DTD XSD
1. DTD are the declarations that define a document type for SGML. XSD describes the elements in a XML document.
2. It doesn’t support namespace. It supports namespace.
3. It is comparatively harder than XSD. It is relatively more simpler than DTD.
4. It doesn’t support datatypes. It supports datatypes.
5. SGML syntax is used for DTD. XML is used for writing XSD.
6. It is not extensible in nature. It is extensible in nature.
7. It doesn’t give us much control on structure of XML document. It gives us more control on structure of XML document.
8. It specifies only the root element. Any element which is made global can be done as root as markup validation.
9. It doesn’t have any restrictions on data used. It specifies certain data restrictions.
10. It is not much easy to learn . It is simple in learning.
11. File here is saved as .dtd File in XSD is saved as .xsd file.
12. It is not a strongly typed mechanism. It is a strongly typed mechanism.
13. It uses #PCDATA which is a string data type. It uses fundamental and primitive data types.

Last Updated : 03 Jan, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads