From: daritter at rttr dot de
Operating system: Linux (Debian/Sid)
PHP version: 5.0.3
PHP Bug Type: DOM XML related
Bug description: Wrong handling of default namespaces
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:
--
Edit bug report at http://bugs.php.net/?id=32289&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32289&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=32289&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=32289&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32289&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32289&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32289&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32289&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32289&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32289&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32289&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=32289&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=32289&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32289&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32289&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32289&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32289&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32289&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32289&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32289&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32289&r=mysqlcfg