|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-05-18 17:52 UTC] mike@php.net
-Status: Open
+Status: Wont fix
[2010-05-18 17:52 UTC] mike@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
Description: ------------ If you add a new namespace to a document root with addAttribute(), the function incorrectly also tries to add a namespace for the new namespace, resulting in a spurious "xmlns:xmlns" attribute. Add attribute called "foo:bar" xmlns:foo="namespace-url" foo:bar="value" <-- correct Add attribute called "xmlns:bar" xmlns:xmlns="namespace-url" xmlns:bar="namespace-url" <-- incorrect A special case is thus needed to ensure that, if the attribute name starts with "xmlns:", a namespace is not added for it: xmlns:bar="namespace-url" <-- correct Alternatively, a new function for adding namespaces to a document? Test script: --------------- <?php $xml = new SimpleXMLElement('<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"/>'); $xml->addAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer', 'http://openoffice.org/2004/writer'); echo $xml->asXML(); ?> Expected result: ---------------- <?xml version="1.0"?> <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooow="http://openoffice.org/2004/writer"/> Actual result: -------------- <?xml version="1.0"?> <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xmlns="http://openoffice.org/2004/writer" xmlns:ooow="http://openoffice.org/2004/writer"/>