And non validating parsers with
Violations of well-formedness constraints are considered fatal errors, according to the XML 1.0 Recommendation.
The bottom line here is: either a document is well-formed XML, or it's toast; that is, it's not XML.
In other words, validating parsers must read the entire DTD and check the document against the structural constraints it describes.
You might conclude, therefore, that nonvalidating parsers do not need to consult the DTD, but that turns out to be incorrect.
In fact, if a document is not well-formed, it cannot even be called an XML document.Because validation can significantly impact performance, especially when long and complex DTDs are involved.Some developers find that while enabling validation during development and test phases is crucial, it's sometimes beneficial to surpress validation in production systems where document throughput is most valued and the reliability of the data is already known.The reason for insisting on well-formedness is to counteract the "browser bloat" syndrome that occurred when the major browser vendors decided they wanted their browser to be able to render the horribly inaccurate HTML developed by graduates (or perhaps flunkies) of the Learn HTML in 2 Days or Less school.
Many Web pages contain completely invalid HTML, with improperly nested elements, missing end tags, misspelled element names, missing delimiters, and other aberrations.Even nonvalidating parsers need to supply default values for attributes and to replace text based on internal entities (discussed in chapter 4).