dagblog.
← Archive

XHTML 1.1 and processing invalid documents


Petr Cimprich’s article Handling errors in XML
 opened an interesting discussion about how an XML parser should behave when it encounters a syntax error. The article
 includes a particularly interesting quotation from the XML 1.0 specification 
 about this error, which is considered fatal:

Once a fatal error is detected, the processor must not continue 
 normal processing (that is, it must not continue to pass on text 
 and information about the logical structure of the document in the usual way).

If we apply those lines to an XHTML 1.1 example, we come up with some 
 interesting questions, or rather unknowns, as Martin Hassman pointed out.
 He also goes by Met (czilla.cz). How should
 browsers behave when handling a document under the XHTML 1.1 DTD
 that is invalid?

If browsers followed the specification exactly, then no invalid
 pages would display. I can hardly imagine that happening, and it probably
 won’t. But browser behavior could depend on quirks and standards modes, with the mode
 switching depending on whether the document is valid.

For an invalid document, the browser would switch to quirks mode and handle it
 like ordinary HTML, where browsers are much more forgiving
 of errors.

Medium version

Related articles

Related CZ Podcast episodes