[Webkit-unassigned] [Bug 13057] New: XML parsing errors reported ambiguously by DOMParser.parseFromString

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Mar 13 09:15:28 PDT 2007


http://bugs.webkit.org/show_bug.cgi?id=13057

           Summary: XML parsing errors reported ambiguously by
                    DOMParser.parseFromString
           Product: WebKit
           Version: 522+ (nightly)
          Platform: Macintosh
        OS/Version: Mac OS X 10.4
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P1
         Component: XML DOM
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: jcostell at tibco.com


For developers trying to figure out whether the parsing of an XML string
succeeder or not, the way that DOMParser reports errors as of r20136 is not
very useful. 

A month ago, the following code would identify an error:

var doc = (new DOMParser()).parseFromString(xml);
var errorNode = (new XPathEvaluator()).evaluate("//parsererror//div",
doc).iterateNext();
if (errorNode) {
    // Error!
}

However, now it appears that the parsererror node is an HTMLElement rather than
an Element and so the XPath query does not select it. The returned document and
its root node are still Document and Element, respectively, so it is not
possible to use getElementsByTagName either. 

The only way I can figure to identify an error is to traverse the entire
returned document and look for either HTMLElements or a node called parsererror
and then look for a div contained in that. 

I'd like to suggest that Firefox handles this in a much more elegant manner.
The same method in Firefox indicates a parsing error by returning a document
with a root element <parsererror
xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml">. There are no
nested elements within the document element, only the text description of the
parse error. In addition to this being very easy for a developer to identify,
it is also unambiguous because of the namespaceURI. 

I hope this can make it into Safari 3.


-- 
Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list