XSD vs. DTD
XML Schema Definition (also known as XSD) is one of a variety of XML schema languages. This particular language was published as a W3C recommendation. It was the prototype language for those that followed that were able to separate schema language for XML, and the first to attain Recommendation status by the W3C. As a means to avoid confusion with other uses of the phrase XML Schema, many users began to refer to the language as WSD (in order to differentiate it as a language that was W3C recommended – standing for W3C XML Schema). Still, other users referred to its more common form, XSD – meaning XML Schema Document.
Document Type Definition (also known as DTD) is a set of markup declarations that are used specifically to define a document type for SGML family markup languages (the three most common of which being SGML, XML and HTML). As it is, DTD is a specific type of XML Schema. DTDs use a terse formal syntax, meaning that it is a markup declaration that declares the exact elements and references that are able to appear in a particular document type. It also declares what the elements’ contents and attributes are. Another important aspect of the DTD is its ability to declare entities which have the possibility of being used in the instance document.
XSD has the ability to be used to express a set of rules to which an XML document must adhere. XML documents must conform to this set of rules in order to be thought of as ‘valid’ according to their particular schema. What differentiates XSD from other XML schema languages is that it was also designed with the idea that determining a document’s validity would produce a collection of information that adhered to specific data types. While this post-validation info set is useful when developing XML document processing software, its dependence on specific data types is a feature that has drawn a considerable amount of criticism.
DTD are prevalent in applications that need special publishing characters (the XML and HTML Character Entity References, for instance). These special publishing characters came from the larger sets which were defined as features of the ISO SGML standard effort. A specific Document Type Definition associates a DTD with an XML document. DTDs crop up in doctypedecl – a syntactic fragment – near the beginning of an XML document. This declaration establishes that the XML document is an instance of a DTD referenced and defined type. There are two specific declarations that the DTD makes: An internal subset, which forms part of the DTD in the document itself, and an external subset, which is located in a separate text file.
1. XSD is an XML schema language recommended throughW3C; DTD is a set of markup declarations used to define a document type.
2. XSD is used to express a set of rules to which an XML document must adhere; a Document Type Definition associates a DTD with an XML document.