php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33305 appendChild adds additionnal namespace on wrong node
Submitted: 2005-06-10 18:10 UTC Modified: 2005-06-10 19:02 UTC
From: francois dot proulx at gmail dot com Assigned:
Status: Not a bug Package: *XML functions
PHP Version: 5.0.4 OS: Linux Mandrake 10.1
Private report: No CVE-ID: None
 [2005-06-10 18:10 UTC] francois dot proulx at gmail dot com
Description:
------------
When adding a node with a different namespace on the second or third level of a DOM tree. DOM adds additionnal namespace declaration to the upper levels where it shoul'nt.

I'm using libxml 2.6.17 or 2.6.19 (same issue). DOM/XML API Version 20031129.

Reproduce code:
---------------
$document = new DomDocument();
$root = $document->createElementNS(OAI_PMH_NS, "OAI-PMH");
$document->appendChild($root);

$get_record_node = $document->createElementNS(OAI_PMH_NS, "GetRecord");
$record_node = $document->createElementNS(OAI_PMH_NS, "record");
$metadata_node = $document->createElementNS(OAI_PMH_NS, "metadata");
$node_bug = $document->createElementNS(LOM_EXPORT_NS, "lom_prefix:lom");

$record_node->appendChild($metadata_node);
$metadata_node->appendChild($node_bug);
$get_record_node->appendChild($record_node);
$root->appendChild($get_record_node);

Expected result:
----------------
<?xml version="1.0"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/">
  <GetRecord>
    <record>
      <metadata>
        <lom_prefix:lom xmlns:lom_prefix="http://ltsc.ieee.org/xsd/LOM"/>
      </metadata>
    </record>
  </GetRecord>
</OAI-PMH>

Actual result:
--------------
<?xml version="1.0"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/">
  <GetRecord xmlns:lom_prefix="http://ltsc.ieee.org/xsd/LOM">
    <record xmlns:lom_prefix="http://ltsc.ieee.org/xsd/LOM">
      <metadata>
        <lom_prefix:lom xmlns:lom_prefix="http://ltsc.ieee.org/xsd/LOM"/>
      </metadata>
    </record>
  </GetRecord>
</OAI-PMH>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-10 19:02 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.

There are a few issues with namespace reconciliation in libxml. They are currently being addressed. In any case the two documents (expected and actual results) although not identical have the same meaning.
 [2012-06-17 08:14 UTC] kerzoloc at free dot fr
appending's order is important:

$root->appendChild($get_record_node);
$get_record_node->appendChild($record_node);
$record_node->appendChild($metadata_node);
$metadata_node->appendChild($node_bug);

<?xml version="1.0"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/">
  <GetRecord>
    <record>
      <metadata>
        <lom_prefix:lom xmlns:lom_prefix="http://ltsc.ieee.org/xsd/LOM"/>
      </metadata>
    </record>
  </GetRecord>
</OAI-PMH>


Bien cordialement
Erwan
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 15:03:14 2021 UTC