Open In App
Related Articles

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

Improve Article
Save Article
Like Article

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) 

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.
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation course.

Last Updated : 03 Jan, 2023
Like Article
Save Article
Similar Reads