Difference between Document Type Definition (DTD) and XML Schema Definition (XSD)
1. 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.
2. 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.|