Re: innerHTML in XML

On Sun, Jun 1, 2008 at 6:54 AM, Cameron McCormack wrote:
>
> Currently the spec says:
>
>  If any of the elements in the serialization are in the null namespace,
>  the default namespace in scope for those elements must be explicitly
>  declared as the empty string.
>    — http://dev.w3.org/html5/spec/#innerhtml1
>
> Is there any reason for this?  Why not allow elements to be in no
> namespace by virtue of there being no xmlns="" attribute in
> ancestor-or-self::*?

You might have misunderstood that sentence (or have I misunderstood yours?)

It says that if an element is in no namespace in the DOM, its
serialization must have xmlns="" (so that you can copy/paste it into a
document no matter whether there's a default namespace without
changing its meaning).
(note that the sentence appears in the context of a paragraph dealing
with the "return value" of innerHTML, so the process of serializing,
not parsing).

If the serialization didn't include the xmlns="" explicitly,
serializing a tree to, e.g.:
  <foo:a xmlns:foo="http://example.net/foo"><b/></foo:a>
Then compare pasting that fragment in the following documents:
  <c xmlns="">[paste here]</c>
vs.
  <d xmlns="http://example.net/foo">[paste here]</d>
Element <b/> wouldn't be the same when re-parsing the compound documents.

With the explicit xmlns="" in the serialization, this cannot happen:
  <foo:a xmlns:foo="http://example.net/foo" xmlns=""><b/></foo:a>

-- 
Thomas Broyer

Received on Sunday, 1 June 2008 09:43:15 UTC