W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2001

Namespace woes

From: Jim Clement <JClement@silverbacktech.com>
Date: Mon, 15 Jan 2001 18:14:15 -0500
To: <www-dom@w3c.org>
Message-ID: <NEBBIBEJNEMOACDBCLOIKEADCEAA.JClement@silverbacktech.com>
I am having a tough time with namespaces and document.importNode(). I am
trying to create an XSL in a DOM for Xalan. The XSL is dynamicaly
constructed from several documents, assembled in memory in a DOM and sent
off to Xalan for processing. The problem I am having, is [for "historical"
reasons] the Document fragments I am aggregating (via
Document.importNode() )have no support for namespaces. I get around this by
dynamically creating a new Document, and I create the root element with a
default namespace like so:

Document xslDocument = new DocumentImpl();
Element xslElement = xslDocument.createElementNS(
"http://www.w3.org/1999/XSL/Transform", "stylesheet" );
xslElement.setAttribute( "version", "1.0" );
xslElement.setAttribute( "xmlns", "http://www.w3.org/1999/XSL/Transform" );

( The line that adds the xmlns attribute is to keep Xalan from
complaining. )

The doc for importNode says "For all nodes, importing a node creates a node
object owned by the importing document, with attribute values identical to
the source node's nodeName and nodeType , plus the attributes related to
namespaces (prefix , localName , and namespaceURI ). "

However, my reading of the namespace spec at w3c suggests that "default
namespaces", i.e. namespaces that require no prefix (like "xsl:") are
heiarchical in nature. For example:

<foo xmlns:"blahblahblah">

I would imagine the bar element would be in the blahblahblah namespace,
whether it was dynamically created or imported. Is this correct? What am I
Received on Monday, 15 January 2001 18:12:53 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:07 UTC