From:             
Operating system: All
PHP version:      5.2.13
Package:          SimpleXML related
Bug Type:         Bug
Bug description:Adding namespace with addAttribute() adds spurious xmlns:xmlns 
attribute

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"/>



-- 
Edit bug report at http://bugs.php.net/bug.php?id=51641&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51641&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51641&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51641&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51641&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51641&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51641&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51641&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51641&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51641&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51641&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51641&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51641&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51641&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51641&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51641&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51641&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51641&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51641&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51641&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51641&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51641&r=mysqlcfg

Reply via email to