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) "xtc: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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php