Why Validate an XML Document?

A validating parser will check if an XML document references a DTD. If it does, the parser will check the content and structure of the document against the DTD.

It's easy to understand why a processor will refuse to display a document that is not well-formed, but why even bother validating a document against a DTD? If XML documents are designed for use over the Internet, why bother sending along the accessory baggage of a DTD? Why not just display the document?

These are all good questions. If the purpose of XML was just to provide a vehicle for document display, there would be no need to bother with a DTD. However, XML documents are not just vehicles for display. They are vehicles for storing and structuring content. ...

Get XML Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.