#47913 [NEW]: AppendNode can change the namespace of an element

From: Date: Tue, 07 Apr 2009 07:33:01 +0000
Subject: #47913 [NEW]: AppendNode can change the namespace of an element
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135615@lists.php.net to get a copy of this message
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

« previous php.bugs (#135615) next »