From: robin2008 at altruists dot org Operating system: Ubuntu PHP version: 5.2.9 PHP Bug Type: DOM XML related Bug description: importNode doesn't preserve attribute namespaces
Description: ------------ I was expecting importNode to preserve attribute namespaces. It doesn't Reproduce code: --------------- <?php // PHP 5.2.* namespace bug - importNode doesn't preserve attribute namespaces $aDOM= new DOMDocument(); $aDOM->appendChild($aDOM->createElementNS('http://friend2friend.net/','f2f:a')); echo 'DOM to add into is '.$aDOM->saveXML().chr(13); $fromdom= DOMDocument::loadXML('<data xmlns:ai=" http://altruists.org " ai:attr="namespaced" />'); echo 'Dom to import from is'.$fromdom->saveXML().chr(13); $attr= $fromdom->firstChild->attributes->item(0); $aDOM->documentElement->appendChild($aDOM->importNode($attr)); echo 'Result is '.$aDOM->saveXML(); // The following script gets round this bug function importAttrNS($targetNode, $attr) { // Last modified 2009-01-26 Imports an attribute without losing the NS, if present if ($attr->prefix=='') $targetNode->appendChild($targetNode->ownerDocument->importNode($attr)); else $targetNode->setAttributeNS($attr->lookupNamespaceURI($attr->prefix), $attr->prefix.':'.$attr->name, $attr->value); } ?> Expected result: ---------------- The imported attribute should keep its namespace. Actual result: -------------- The imported attribute becomes unnamespaced. -- Edit bug report at http://bugs.php.net/?id=47848&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47848&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47848&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47848&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47848&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47848&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47848&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47848&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47848&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47848&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47848&r=support Expected behavior: http://bugs.php.net/fix.php?id=47848&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47848&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47848&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47848&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47848&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47848&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47848&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47848&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47848&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47848&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47848&r=mysqlcfg