-
DTDs are coded using a special language, whereas XSDs are coded in XML.
-
XSDs can be processed just like any other XML documents.
-
XSDs support a variety of data types (integer numbers, floating point numbers, Booleans [true/false], dates, and so on), whereas DTDs treat all data as strings or lists of strings.
-
XSDs present an open-ended data model, which allows you to extend custom markup languages and establish complex relationships between elements without invalidating documents. DTDs employ a closed data model that doesn't allow for much in the way of extensibility.
This list of differences obviously tips the scales in favor of XSDs. This is not just a matter of me being enamored with XML Schema. Keep in mind that XML Schema was created long after DTDs, so it stands to reason that it would address many of the weaknesses found in DTDs. Knowing this, you might think that it's a no-brainer choosing XSDs over DTDs to describe the data model for all of your XML documents. Although XSDs represent a more modern approach to XML data modeling, DTDs aren't quite dead yet. The one thing DTDs have going for them is the fact that they've been around for so long and are so widely accepted. If you think an inferior technology has never been able to survive solely on its longevity and widespread acceptance, think again. Look no further than your VCR to see such a technology in action; Betamax was known to be a more powerful technology but somehow the VHS standard stuck and the better technology lost. Even so, DTDs are being supplanted by XML Schema and other schema standards such as the newer RELAX NG schema technology.
One compelling argument for understanding DTDs is that many XML-based markup languages are still expressed as DTDs. So, if you plan on using any existing XML languages, you may need to be familiar with DTDs in order to understand how they work. The other point to keep in mind is that DTDs are actually very good at describing the structure of XML documents. The fact that XSDs do a better job is not enough to discount DTDs entirely.