From: robin2008 at altruists dot org
Operating system: Ubuntu
PHP version: 5.2.9
PHP Bug Type: DOM XML related
Bug description: AppendNode can change the namespace of an element
Description:
------------
After appendChild, the namespace prefix gets lost, so it inherits the
namepsace from the parent xmlns.
Reproduce code:
---------------
// PHP 5.2.* namespace bug - appendChild() changes the namespace
$aDOM= DOMDocument::loadXML('<f2f:o xmlns:f2f=" http://friend2friend.net "
xmlns:default="default"><default:i
xmlns="default"><f2f:watch-me/></default:i></f2f:o>');
echo 'Initial DOM is '.$aDOM->saveXML().chr(13);
$newNode= $aDOM->createElementNS(" http://friend2friend.net ",
'newnode');
$newNode->appendChild($aDOM->documentElement);
echo 'Appending the document Element to f2f:newnode, it all looks OK:
'.chr(13).$aDOM->saveXML($newNode).chr(13).chr(13);
$aDOM->appendChild($newNode);
echo 'But adding <f2f:newnode> back as the documentElement changes a
namespace '.$aDOM->saveXML();
Expected result:
----------------
Should keep the original namespace:
<newnode xmlns=" http://friend2friend.net " xmlns:default="default"><o
xmlns:f2f=" http://friend2friend.net " xmlns:default="default"><default:i
xmlns="default"><f2f:watch-me/></default:i></o></newnode>
Actual result:
--------------
Loses the namespace prefix, so it inherits a different one the from xmlns
of the parent node
<newnode xmlns=" http://friend2friend.net " xmlns:default="default"><o
xmlns:f2f=" http://friend2friend.net " xmlns:default="default"><default:i
xmlns="default"><watch-me/></default:i></o></newnode>
--
Edit bug report at http://bugs.php.net/?id=47913&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47913&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47913&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47913&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47913&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47913&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47913&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47913&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47913&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47913&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47913&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47913&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47913&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47913&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47913&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47913&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47913&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47913&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47913&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47913&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47913&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47913&r=mysqlcfg