From: sgunderson at bigfoot dot com
Operating system: Debian
PHP version: 5.2.9
PHP Bug Type: DOM XML related
Bug description: Importing objects into document fragments creates bogus
"default" namespace
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 bug report at http://bugs.php.net/?id=47530&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47530&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47530&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47530&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47530&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47530&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47530&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47530&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47530&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47530&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47530&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47530&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47530&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47530&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47530&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47530&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47530&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47530&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47530&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47530&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47530&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47530&r=mysqlcfg