Feature Post

Top

DTD v/s XSD: And What is DSD?

DTD v/s XSD:

Since I have looking into the XML schemas and validators, I was wondering about the differences between a DTD and XSD. Which one would we use when? And why?
Following are a couple of differences that I am able to conclude.

Sample Bookstore.XML

Data type definition(DTD):
• DTD provides a basic grammar for defining a document(HTML/XML/etc); its elements, attributes, their nesting and ordering.
• Namespaces cant be defined in DTD
• Hard to extend once written
• The language to define a DTD is called MNF; I forgot but it’s like Markus-Naum language.
• Requires a specific parser
• No builtin data types
• Matured/proven industry standard and is been in the industry for a while now
• Freely available for re-use

Bookstore.DTD

XML Schema definition(XSD):

• Includes full capabilities provided by DTD
• Is Namespace'able
• Since the document is based upon xml standards, the normal xml parse is used to parse the xsd document.
• Can define data types, elements, attributes, nestings, orderings, etc; and what the data can/cannot contain.
• Easily extendable
• Since its based upon XML, I believe its easily learnable.
• Contains builtin data types
• XML document has an XML Namespace to refer to and an XML DTD to define it. This becomes overhead when a parser examines the document, it may have to link this all in, interpret the DTD for the schema, load the namespace, and validate the schema; all before it can parse the actual XML document; this overhead may seriously degrade performance or system availability.

Bookstore.XSD



If you like to look more, the Document Structure Description(DSD) defines the next generation schema languages, see examples.