Re: Missing namespaceURI after importNode()

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

 



Nathan Rixham wrote:
Tim Lind wrote:
Hi


I am importing a node into a new document so that I can perform an XSL transformation on just that node. This works sometimes, however, I've come into the following problem, where the namespaceURI is there on the node but doesn't make it through the importNode() to the next document.

Can you tell me what might be the cause of loosing the namespace on importing the node? Bearing in mind that the childnode itself (being the result of an xsl transformation) was previously imported into the document as a replacement for it's original node.

I'm using PHP 5 DOM and XSL extensions.



Tim


CODE SNIPPET:


# ...$childNode exists previous to this point

echo "\n --- source node --- \n";

echo $this->srcDocument->saveXML($childNode);
var_dump($childNode->namespaceURI);

# importing childnode into a new doc

$newDoc = new DOMDocument();
$newRoot = $newDoc->importNode($childNode, true);
$newDoc->appendChild($newRoot);

echo "\n --- import of source node --- \n";

echo $newDoc->saveXML($newRoot);
var_dump($newRoot->namespaceURI);

# will be using newDoc for an XSL transformation and replacing childNode
# with the new doc,
# (which is what was previously done successfully with child node)


OUTPUT SNIPPET:

 --- source node ---
<pre:name/>string(15) "website.com"


 --- import of source node ---
<name/>NULL

xmlns for pre isn't in the main doc.. if you add the namespace to the node you're importing in element it should stick

I'm not sure I know what you mean, the namespace (website.com) is printed there in the original document. Importing the node should copy the namespace.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux