|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-09-28 11:42 UTC] rrichards@php.net
[2008-09-29 16:53 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
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>