From: robin2008 at altruists dot org
Operating system: Ubuntu
PHP version: 5.2.6
PHP Bug Type: DOM XML related
Bug description: importNode changes the namespace of an XML element.
Description:
------------
The problem occurs when an element has an unused namespace node
xmlns:default which is hanging around, unused.
When imorting a node under certain conditions, the parent node sets an
xmlns:default which is intended to apply to the imported Node, but doesn't
because xmlns:default applies instead.
The net effect is that the imported node changes namespace.
Reproduce code:
---------------
<?php
$aDOM = new DOMDocument;
$aDOM->loadXML('<?xml version="1.0"?><f2f:a
xmlns:f2f="http://friend2friend.net"/>');
$a= $aDOM->firstChild;
echo 'DOM is add into is '.$aDOM->saveXML().chr(13);
$ok = new DOMDocument;
$ok->loadXML('<f2f:ok xmlns:f2f="http://friend2friend.net"
xmlns="REAL"><watch-me xmlns:default="BOGUS"/></f2f:ok>');
$imported= $aDOM->importNode($ok->firstChild, true);
echo 'Node to import is '.$aDOM->saveXML($imported).chr(13).chr(13);
$a->appendChild($imported);
echo 'Result is '.$aDOM->saveXML();
?>
Expected result:
----------------
DOM is add into is <?xml version="1.0"?>
<f2f:a xmlns:f2f="http://friend2friend.net"/>
Node to import is <f2f:ok xmlns:f2f="http://friend2friend.net"
xmlns="REAL"><watch-me xmlns:default="BOGUS"/></f2f:ok>
Result is <?xml version="1.0"?>
<f2f:a xmlns:f2f="http://friend2friend.net"><f2f:ok
xmlns:default1="REAL"><default1:watch-me
xmlns:default="BOGUS"/></f2f:ok></f2f:a>
Actual result:
--------------
DOM is add into is <?xml version="1.0"?>
<f2f:a xmlns:f2f="http://friend2friend.net"/>
Node to import is <f2f:ok xmlns:f2f="http://friend2friend.net"
xmlns="REAL"><watch-me xmlns:default="BOGUS"/></f2f:ok>
Result is <?xml version="1.0"?>
<f2f:a xmlns:f2f="http://friend2friend.net"><f2f:ok
xmlns:default="REAL"><default:watch-me
xmlns:default="BOGUS"/></f2f:ok></f2f:a>
--
Edit bug report at http://bugs.php.net/?id=46185&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=46185&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=46185&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=46185&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46185&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=46185&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46185&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46185&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46185&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46185&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46185&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=46185&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=46185&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46185&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46185&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46185&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46185&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46185&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46185&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46185&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46185&r=mysqlcfg