classpathx-xml
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Classpathx-xml] Automatic xmlns attributes on the document element


From: Elliotte Rusty Harold
Subject: [Classpathx-xml] Automatic xmlns attributes on the document element
Date: Mon, 31 Dec 2001 16:34:31 -0500

Consider the following code fragment which begins the creation of an SVG
document as a DOM Document object:

  Document doc = impl.createDocument(
    "http://www.w3.org/2000/svg";, "svg", svgDOCTYPE);
  Node rootElement = doc.getDocumentElement();

This creates a document with an svg root element in the
http://www.w3.org/2000/svg namespace.

According to section 1.1.8 of the DOM level 2 spec rootElement should
not have an attribute for xmlns="http://www.w3.org/2000/svg";.
Specifically, "Similarly, creating a node with a namespace prefix and
namespace URI, or changing the namespace prefix of a node, does not
result in any addition, removal, or modification of any special
attributes for declaring the appropriate XML namespaces. Namespace
validation is not enforced; the DOM application is responsible. In
particular, since the mapping between prefixes and namespace URIs is not
enforced, in general, the resulting document cannot be serialized
naively. For example, applications may have to declare every namespace
in use when serializing a document."

When I run this code with Xerces-J 1.4.3 and Crimson 1.1.3 rootElement
does not have any attributes, which is correct. When I run this code
with GNU-JAXP 1.0-beta-1 it does have such an attribute. I strongly
suspect this is a bug. 

-- 
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | address@hidden | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|               Java I/O (O'Reilly & Associates, 1999)               |
|            http://www.ibiblio.org/javafaq/books/javaio/            |
|   http://www.amazon.com/exec/obidos/ISBN=1565924851/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      | 
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+



reply via email to

[Prev in Thread] Current Thread [Next in Thread]