[w3c/DOM-Parsing] XML null namespaces are not preserved (#47)

When serializing a node that does not belong in *any* (including the default) namespace, it is important to preserve that fact. XMLSerializer/DOMParser objects have long supported such serialization via the `xmlns=""` mechanism, which instructs the parser to *not* place the element in the default namespace, but that the element should have *no* namespace.

This behavior is detailed in the XML namespaces specification, [Namespaces in XML 1.0 (Third Edition)](https://www.w3.org/TR/xml-names/#defaulting): `"The attribute value in a default namespace declaration MAY be empty. This has the same effect, within the scope of the declaration, of there being no default namespace."`

As a quick example, consider this:

```
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <people xmlns="">
      <person>
        <lastname>Smith</lastname>
        <firstname>Joe</firstname>
      </person>
      <person>
        <lastname>Jones</lastname>
        <firstname>John</firstname>
      </person>
    </people>
  </head>
  <body>
    <button onclick="alert_serialization()">Alert the namespace</button>
  </body>
</html>
```

The `people` element and all of its descendants should be considered to be in **no namespace whatsoever** (i.e. they do **not** inherit the XHTML namespace).

This is a critical distinction that has impact in many areas, but especially things like Path querying.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/DOM-Parsing/issues/47

Received on Monday, 11 March 2019 14:09:44 UTC