php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49282 importNode() looses namespaceURI value
Submitted: 2009-08-17 16:53 UTC Modified: 2010-01-29 18:35 UTC
From: daniel at webdevelopers dot cz Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.3.0 OS: Ubuntu 2.6.21 i686
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daniel at webdevelopers dot cz
New email:
PHP Version: OS:

 

 [2009-08-17 16:53 UTC] daniel at webdevelopers dot cz
Description:
------------
libxml 2.6.31

When importing previously removed element into the new document the namespaceURI is not preserved.

It is preserved only if the @xmlns declaration attribute is present on the element itself. Does not work if it was declared on former ancestor.

Reproduce code:
---------------
$rcpt=new DOMDocument; $rcpt->loadXML("<rcpt></rcpt>");
// XMLNS on parent
$dnr1=new DOMDocument; $dnr1->loadXML("<dnr xmlns:sys='http://www.1stomni.com/spire'><sys:donate/></dnr>");
// XMLNS on element
$dnr2=new DOMDocument; $dnr2->loadXML("<dnr><sys:donate xmlns:sys='http://www.1stomni.com/spire'/></dnr>");

getGift($rcpt, $dnr1->documentElement->removeChild($dnr1->documentElement->firstChild));
getGift($rcpt, $dnr2->documentElement->removeChild($dnr2->documentElement->firstChild));

function getGift($dom, $gift) {
	echo "before: \"$gift->namespaceURI\"; after: \"".$dom->documentElement->appendChild($dom->importNode($gift))->namespaceURI."\"\n";
}


Expected result:
----------------
before: "http://www.1stomni.com/spire"; after: "http://www.1stomni.com/spire"
before: "http://www.1stomni.com/spire"; after: "http://www.1stomni.com/spire"


Actual result:
--------------
before: "http://www.1stomni.com/spire"; after: ""
before: "http://www.1stomni.com/spire"; after: "http://www.1stomni.com/spire"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-29 18:35 UTC] rrichards@php.net
This was a bug in the libxml2 library and fixed there. Will be in the 
2.7.7 release
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 11:02:27 2025 UTC