Prefixes and setting innerHTML in XML

Step 2 in setting innerHTML in XML says:

    If the innerHTML attribute is being set on an element, the user agent
    must feed the parser just created the string corresponding to the start
    tag of that element, declaring all the namespace prefixes that are in
    scope on that element in the DOM, as well as declaring the default
    namespace (if any) that is in scope on that element in the DOM.

But what does "all the namespace prefixes that are in scope on that  
element in the DOM" actually mean? Does it mean xmlns:foo attributes (in  
the XMLNS namespace)? Does it mean elements that have non-empty .prefix?  
Both? What if the DOM contains namespace declarations and/or prefixes that  
are conflicting or illegal?


Consider e.g.:

    var e =  
document.createElementNS('http://www.w3.org/1999/xhtml','foo:div');
    e.innerHTML = '<foo:img/>';
    e.innerHTML = '<img/>';
    e.setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:foo','bar:');
    e.innerHTML = '<foo:img/>';
    e.setAttributeNS('http://www.w3.org/2000/xmlns/','xmlns:xml','bar:');
    e.innerHTML = '';


(It seems that Firefox only inserts explicit namespace declarations.  
Safari inserts a default namespace declaration for the XHTML namespace,  
catches well-formedness errors but not namespace-well-formedness errors.  
Opera still uses the HTML parser for setting innerHTML in XML.)

-- 
Simon Pieters
Opera Software

Received on Wednesday, 4 June 2008 16:02:28 UTC