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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 19:01:29 2024 UTC