Edit report at http://bugs.php.net/bug.php?id=47530&edit=1
ID: 47530 Updated by: fel...@php.net Reported by: sgunderson at bigfoot dot com Summary: Importing objects into document fragments creates bogus "default" namespace -Status: Open +Status: Assigned Type: Bug Package: DOM XML related Operating System: Debian PHP Version: 5.2.9 -Assigned To: +Assigned To: rrichards Previous Comments: ------------------------------------------------------------------------ [2009-02-28 14:48:20] sgunderson at bigfoot dot com Description: ------------ Hi, When I import a DOM node via a document fragment, suddenly a "default" namespace comes out of nowhere (and it's really hard to remove, short of making my own cloneNode() simulation stripping it). IIRC PHP4 got this right (although it had lots of other issues), and all other languages I've tested in (Perl, Python, Ruby) do as well. Note that the code below doesn't strictly need importNode(), but I cannot really do with cloneNode() in the real code (it's vastly simplified). Note: On the surface, this appears to be the same bug as #46185, but I tested 5.3 CVS (as of 2009-02-28) and it's still there. Reproduce code: --------------- <?php $doc = new DOMDocument; $doc->loadXML('<html xmlns="something" xmlns:ns="whatever"><element ns:foo="bar" /></html>'); $root = $doc->documentElement; $elem = $root->firstChild; $frag = $doc->createDocumentFragment(); $frag->appendChild($doc->importNode($elem)); $root->appendChild($frag); print $doc->saveXML(); ?> Expected result: ---------------- <?xml version="1.0"?> <html xmlns="something" xmlns:ns="whatever"><element ns:foo="bar"/></html> Actual result: -------------- <?xml version="1.0"?> <html xmlns="something" xmlns:ns="whatever"><default:element xmlns:default="something" xmlns:ns="whatever" ns:foo="bar"/></html> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=47530&edit=1