Can Browsers Attempt to Render Broken XHTML?

On Wednesday, June 25, 2003, at 03:42  PM, Matt May wrote:

>
> On Wednesday, June 25, 2003, at 02:32  PM, Kynn Bartlett wrote:
>> Where's the requirement that SGML-based HTML should not display an
>> invalid Strict document?
>
> You're right, there is no MUST NOT clause in the Conforming User 
> Agents section of the HTML 4.01 spec.[1]
>
> Nor is there one in the XHTML 1 spec.[2] In fact, they're pretty much 
> identical in terms of recovering from elements and attributes they 
> don't understand. The XHTML spec says that it has to parse the 
> document as XML, but doesn't say thou shalt not render if it fails.
>
> [1] http://www.w3.org/TR/html401/appendix/notes.html#h-B.1
> [2] http://www.w3.org/TR/xhtml1/#uaconf

 From your reference [2]:

   A conforming user agent must meet all of the following criteria:

   1.  In order to be consistent with the XML 1.0 Recommendation [XML], 
the user
       agent must parse and evaluate an XHTML document for 
well-formedness. If
       the user agent claims to be a validating user agent, it must also 
validate
       documents against their referenced DTDs according to [XML].

 From the reference [XML] above:
http://www.w3.org/TR/2000/REC-xml-20001006

   well-formedness constraint

     [Definition: A rule which applies to all well-formed XML documents.
      Violations of well-formedness constraints are fatal errors.]

Okay, so if an XHTML document is not well-formed, that's a fatal error. 
  What
should a user agent do with a fatal error?  Let's see what else [XML] 
says:

   fatal error

    [Definition: An error which a conforming XML processor must detect 
and
     report to the application. After encountering a fatal error, the
     processor may continue processing the data to search for further 
errors
     and may report such errors to the application. In order to support
     correction of errors, the processor may make unprocessed data from
     the document (with intermingled character data and markup) available
     to the application. Once a fatal error is detected, however, the
     processor must not continue normal processing (i.e., it must not
     continue to pass character data and information about the document's
     logical structure to the application in the normal way).]

Read the final "i.e." statement carefully.

A browser is _not_ allowed to "recover gracefully" if it detects a
problem (lack of well-formedness) in an XHTML document.  At best, it
can dump the source code in some way, but the XML parser is specifically
_forbidden_ from trying to pretend as if it has a structured document.

--Kynn

--
Kynn Bartlett <kynn@idyllmtn.com>                     http://kynn.com
Chief Technologist, Idyll Mountain                http://idyllmtn.com
Shock & Awe Blog                                http://shock-awe.info
Author, CSS in 24 Hours                       http://cssin24hours.com
Inland Anti-Empire Blog                   http://inlandantiempire.org

Received on Wednesday, 25 June 2003 20:00:02 UTC