php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37763 cloneNode doesn't clone namespaces of attributes
Submitted: 2006-06-09 13:22 UTC Modified: 2006-06-09 14:42 UTC
From: storm at rustex dot ru Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.4 OS: Windows 2003, FreeBSD 5.4
Private report: No CVE-ID: None
 [2006-06-09 13:22 UTC] storm at rustex dot ru
Description:
------------
Try to work with Microsoft XML SpreadSheet. When I try clone "Column" element and insert it, namespaces of its attributes doesn't save. But if I rewrite attributes with setAttributeNS(getAttributeNS), this attribute save normal.
Sorry for bad english, see example below.

Reproduce code:
---------------
xls.xml
------------------------
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="xxx">
<Table>
<Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="46.5"/>
</Table>
</Worksheet>
</Workbook>
------------------------

code:
------------------------
$xls = new DOMDocument();
$xls->load("xls.xml");
$column = $xls->getElementsByTagName('Column')->item(0);
$column2 = $column->parentNode->insertBefore($column->cloneNode(), $column);
echo $xls->save("xls2.xml");

Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Worksheet ss:Name="xxx">
<Table>
<Column StyleID="s21" AutoFitWidth="0" Width="46.5"/><Column ss:StyleID="s21" ss:AutoFitWidth="0" ss:Width="46.5"/>
</Table>
</Worksheet>
</Workbook>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-09 14:42 UTC] rrichards@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

libxml2 bug occuring due to the default namespace being the same as the ss prefix'd namespace.

Workaround is to use one of the following:
 - either not use the default namespace (prefixing everything with ss:)
 - prefix the parent node to which clone is being appendded to. In this case you would need ss:Table.
 - redefine the xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" declaration on the Table element.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 03:01:23 2020 UTC