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

Re: Namespace woes

From: Gareth Reakes <gareth@decisionsoft.com>
Date: Tue, 16 Jan 2001 08:52:49 +0000 (GMT)
To: Jim Clement <JClement@silverbacktech.com>
cc: www-dom@w3c.org, www-dom@w3.org
Message-ID: <Pine.LNX.4.21.0101160849290.1147-100000@localhost.localdomain>
The problem you are having is that namespaces are assigned at parse time,
or if you dynamically create elements/attiributes at creation time with
the createxxxNS(). Just moving an element into the "scope" of a default
namespace attribute will not assign it a namespace. In fact a nodes
namespace cannot be changed once it has been created.
	
Gareth

On Mon, 15 Jan 2001, Jim Clement wrote:

> 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">
> <bar>
> </foo>
> 
> 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
> missing?
> 
> 
Received on Tuesday, 16 January 2001 03:52:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT