Difference Between XML Schema and DTD
DTD, or Document Type Definition, and XML Schema, which is also known as XSD, are two ways of describing the structure and content of an XML document. DTD is the older of the two, and as such, it has limitations that XML Schema has tried to improve. The first difference between DTD and XML Schema, is namespace awareness; XML Schema is, while DTD is not. Namespace awareness removes the ambiguity that can result in having certain elements and attributes from multiple XML vocabularies, by giving them namespaces that put the element or attribute into context.
Part of the reason why XML Schema is namespace aware while DTD is not, is the fact that XML Schema is written in XML, and DTD is not. Therefore, XML Schemas can be programmatically processed just like any XML document. XML Schema also eliminates the need to learn another language, as it is written in XML, unlike DTD.
Another key advantage of XML Schema, is its ability to implement strong typing. An XML Schema can define the data type of certain elements, and even constrain it to within specific lengths or values. This ability ensures that the data stored in the XML document is accurate. DTD lacks strong typing capabilities, and has no way of validating the content to data types. XML Schema has a wealth of derived and built-in data types to validate content. This provides the advantage stated above. It also has uniform data types, but as all processors and validators need to support these data types, it often causes older XML parsers to fail.
A characteristic of DTD that people often consider both as an advantage and disadvantage, is the ability to define DTDs inline, which XML Schema lacks. This is good when working with small files, as it allows you to contain both the content and the schema within the same document, but when it comes to larger documents, this can be a disadvantage, as you pull content every time you retrieve the schema. This can lead to serious overhead that can degrade performance.
1. XML Schema is namespace aware, while DTD is not.
2. XML Schemas are written in XML, while DTDs are not.
3. XML Schema is strongly typed, while DTD is not.
4. XML Schema has a wealth of derived and built-in data types that are not available in DTD.
5. XML Schema does not allow inline definitions, while DTD does.
Search DifferenceBetween.net :
Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.
Leave a Response