[whatwg] XMLHttpRequest.responseXML and invalid XML documents

Hallvord Reiar Michaelsen Steen hallvord at hallvord.com
Mon Jan 30 21:34:44 PST 2006


On 25 Jan 2006 at 20:54, Hallvord Reiar Michaelsen Ste wrote:

> > Spec says about responseXML : 
> > > If the document was not an XML document, or if the document could
> > > not be parsed (due to an XML well-formedness error or unsupported
> > > character encoding, for instance), returns null.

All UAs I test in ignore an unknown character encoding value and 
parses the document anyway. I'm not sure if the sentence above is 
meant to distinguish between charset="bogus-charset" and charset="utf-
64" (in other words, a charset the UA might be aware that it doesn't 
support - as opposed to a completely uknown one).

Suggest removing the unsupported character encoding statement from 
this sentence. The spec should say that when an unknown character 
encoding is used the UA should assume UTF-8 and move on with parsing.

This is what Opera and FireFox do (consistently) and what IE does but 
only for responseText. IE creates an empty responseXML document if 
charset is unknown.

Currently the spec says only text/xml, application/xml or content-
types ending with +xml will cause the UA to create a responseXML 
document. I suggest this should also apply to text/html if the 
document is wellformed. This is implemented in Opera.

Proposed new text:

   <dd>If the <code title="XMLHttpRequest.readyState"><a
    href="#readystate">readyState</a></code> attribute has a value other than
    4 (Loaded), returns null. Otherwise, if the <code>Content-Type</code>
    header is either <code>text/html</code>, <code>text/xml</code>, 
    <code>application/xml</code>, or ends in <code>+xml</code>,
    returns an object that implements the Document interface
    representing the parsed document. If the document was not an
    XML document, or if the document could not be parsed (due to an XML
    well-formedness error, for instance), returns an empty document.</dd>

-- 
Hallvord Reiar Michaelsen Steen
http://www.hallvord.com/





More information about the whatwg mailing list