Serializing XML with innerHTML (detailed review of the DOM)

(This is part of my detailed review of the Document Object Model section.)

Consider the following document:

    <h:p xmlns:h=""><x/></h:p>

When getting innerHTML on the root element, should the serialization  
declare the no namespace explicitly as in <x xmlns=""/>? (I think it  
should because setting innerHTML will imply namespace declarations so it  
might change meaning if you insert it somewhere else with innerHTML.)

Also, the spec says:

    In an XML context, the innerHTML DOM attribute on HTMLElements and
    HTMLDocuments, on getting, must return a string in the form of an
    internal general parsed entity [...]

...and then goes on to say that some DocumentType nodes must raise an  
exception, however internal general parsed entities can't have doctypes in  
the first place. Are doctypes to be removed from the serialization? If so,  
why should some of them raise an exception? Or should the attribute on the  
HTMLDocument interface return a string in the form of a document? If the  
latter, should an exception be raised if there is no root element?

Finally, the spec lists the following as something that throws:

    A Text node whose data contains characters that are not matched by the
    XML Char production. [XML]

But Text data is not the only case that might not match the Char  
production in XML. Comment data, CDATASection data, ProcessingInstruction  
target, and, I think, Attr value.

Simon Pieters
Opera Software

Received on Tuesday, 11 September 2007 11:48:05 UTC