php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32289 Wrong handling of default namespaces
Submitted: 2005-03-13 12:08 UTC Modified: 2005-03-14 13:28 UTC
From: daritter at rttr dot de Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.3 OS: Linux (Debian/Sid)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daritter at rttr dot de
New email:
PHP Version: OS:

 

 [2005-03-13 12:08 UTC] daritter at rttr dot de
Description:
------------
When generating childs of an element with a default namespace  using DOMDocument->createElement() the namespace of the childs won't be set to the correct value.

Reloading the DOMDocument using saveXML() and loadXML() fixes the Problem.

Reproduce code:
---------------
$xml = new DOMDocument("1.0","UTF-8");
$foo = $xml->createElementNS('urn:foo','foo');
$xml->appendChild($foo);
$bar = $xml->createELement('bar','Bar using default namespace');
$foo->appendChild($bar);
/* results in
<foo xmlns="urn:foo"><bar>Bar using default namespace</bar></foo>
*/

$xsl = DOMDocument::Load('test.xsl');
$xslt = new xsltProcessor();
$xslt->importStylesheet($xsl);

print($xslt->transformToXML($xml));

print("\n\nReload DOM\n");
$xml = DOMDocument::LoadXML($xml->saveXML());
print($xslt->transformToXML($xml));

-----------test.xsl-------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:foo="urn:foo"
>
<xsl:output method="text" omit-xml-declaration = "yes"/>
<xsl:template match="foo:foo">
foo:bars:<xsl:apply-templates select="foo:bar"/>
bars:<xsl:apply-templates select="bar"/>
</xsl:template>

<xsl:template match="*">
	- <xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>


Expected result:
----------------
foo:bars:
	- Bar using default namespace
bars:

Reload DOM

foo:bars:
	- Bar using default namespace
bars:

Actual result:
--------------
foo:bars:
bars:
	- Bar using default namespace

Reload DOM

foo:bars:
	- Bar using default namespace
bars:

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-14 13:28 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. 

Even if you think it is not a bug, we often know better than you,
please consult the support channels first before even considering
to reopen this report.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 13:01:35 2025 UTC