From: Operating system: Linux PHP version: trunk-SVN-2011-07-27 (snap) Package: DOM XML related Bug Type: Bug Bug description:DOMDocument::importNode shifts namespaces when "default" namespace exists
Description: ------------ When importing nodes and their children via DOMDocument::importNode, the method will introduce the "default" namespace prefix. Herein lies a bug that will trigger if the namespace prefix "default" is already assigned (even if not applied to any element) within the children of the imported node. Test script: --------------- <?php $aDOM=DOMDocument::loadXML(<<<EOXML <A xmlns="http://example.hilses.de/A"> <B> <C xmlns="http://example.hilses.de/C" xmlns:default="http://example.hilses.de/Z" /> </B> </A> EOXML ); $bDOM=new DOMDocument(); $node = $bDOM->importNode($aDOM->getElementsByTagNameNS('http://example.hilses.de/A','B')->item(0), true); $bDOM->appendChild($node); echo $bDOM->saveXML()."\n"; ?> Expected result: ---------------- <?xml version="1.0"?> <B xmlns="http://example.hilses.de/A" xmlns:default="http://example.hilses.de/C"> <default:C /> </B> or even better: <?xml version="1.0"?> <B xmlns="http://example.hilses.de/A"> <C xmlns="http://example.hilses.de/C"/> </B> Actual result: -------------- <?xml version="1.0"?> <B xmlns="http://example.hilses.de/A" xmlns:default="http://example.hilses.de/C"> <default:C xmlns="http://example.hilses.de/C" xmlns:default="http://example.hilses.de/Z"/> </B> (see how C is put into the ".../Z" namespace now instead of ".../C", since namespace prefix declarations are valid for the element in which they are defined!) -- Edit bug report at https://bugs.php.net/bug.php?id=55294&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55294&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55294&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55294&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55294&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55294&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55294&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55294&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55294&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55294&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55294&r=support Expected behavior: https://bugs.php.net/fix.php?id=55294&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55294&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55294&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55294&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55294&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55294&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55294&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55294&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55294&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55294&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55294&r=mysqlcfg