What are the pros / cons in DTD and XML Schemas (I’m not even sure what the official name of the latter is!)? Which is better? Why do we need two ways to do the same thing?
Edit: I found this in an article I was reading, which is what prompted me to ask the question:
Why W3C XML Schema Language?
The W3C XML Schema Language is not the
only schema language. In fact, the XML
specification describes document-type
definitions (DTDs) as the way to
express a schema. In addition,
pre-release versions of the JAXB
Reference Implementation worked only
with DTDs — that is, not with schemas
written in the XML Schema Language.
However, the XML Schema Language is
much richer than DTDs. For example,
schemas written in the XML Schema
Language can describe structural
relationships and data types that
can’t be expressed (or can’t easily be
expressed) in DTDs. There are tools
available to convert DTDs to the W3C
XML Schema Language, so if you have
DTD-based schemas that you used with
an earlier version of the JAXB
Reference Implementation, you can use
these tools to convert the schemas to
XML Schema Language. http://java.sun.com/developer/technicalArticles/WebServices/jaxb/#binsch
I guess I would like examples that illustrate why XML-Schema is better (if it indeed is).
From http://weblogs.asp.net/rchartier/archive/2006/03/21/440782.aspx
For my part, it’s pretty straightforward to write a validator for some XML if you have an XSD. I haven’t seen this with a DTD, although I’m sure it exists.