- From: Jim Clement <JClement@silverbacktech.com>
- Date: Mon, 15 Jan 2001 18:14:15 -0500
- To: <www-dom@w3c.org>
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 Monday, 15 January 2001 18:12:53 UTC