It is a truth universally acknowledged that “DTDs don’t support namespaces”. Or to be a little more pedantic, that DTDs don’t support namespaces in their full generality. However, one might as well say that XML 1.0 does not support namespaces. Given that the specification of Namespaces in XML augments XML 1.0, it seems more reasonable to ask why don’t namespaces support DTDs?
The specification for namespaces in XML makes no attempt at supporting DTDs, merely including a paragraph describing the lack of support:
Note that DTD-based validation is not namespace-aware in the following sense: a DTD constrains the elements and attributes that may appear in a document by their uninterpreted names, not by (namespace name, local name) pairs. To validate a document that uses namespaces against a DTD, the same prefixes must be used in the DTD as in the instance.
Lack of support for DTDs seems like a serious omission in the specification of namespaces, and one that could have been easily remedied. For example, a processing instruction could have been introduced to define namespace prefixes within DTDs:
<?xmlns html href="http://www.w3.org/1999/xhtml"?> <!ELEMENT html:title (#PCDATA)>
This would allow a namespace aware XML parser that performs validation to match elements based on their namespace name, not just their prefix, and allows the prefix used in the document to differ from the prefix used in the DTD. There would also need to be rules describing how validation applies to xmlns attributes in the document; I think that the easiest solution here is just to ignore them, as most other schema languages do.
The xmlns processing instruction would fit in with the goals of namespaces in XML by creating a strict subset of the existing XML 1.0 syntax that is still backwards compatible with older parsers. More importantly, it would remove a major limitation that has affected many XML users. Why wasn’t something like this specified in the beginning?