From:             molily at gmx dot de
Operating system: Gentoo Linux
PHP version:      5CVS-2005-08-27 (snap)
PHP Bug Type:     DOM XML related
Bug description:  setAttributeNS doesn't work with non-prefixed attributes from 
default namespace

Description:
------------
It's not possible to use hasAttributeNS and getAttributeNS on attributes
from the default namespace (i.e. without namespace prefix). They do not
find the right attribute.

In addition to this, setAttributeNS cannot set an attribute in the default
namespace. The new atttribute gets an incorrect namespace prefix.

I'm using the latest source snapshot php5-200508262230 (standard
configuration but --without-pear) with libxml 2.6.20 (-r2 in Gentoo
Portage).

Is this a libxml problem, like many DOM extension bugs before? Or do I
misunderstand DOM 2 Core / XML Namespaces?

Reproduce code:
---------------
<?php
$dom = DOMDocument::loadXML('<a xmlns="http://namespaces.molily.de/x";
xmlns:y="http://namespaces.molily.de/y"; attra="attra" y:attrb="attrb"
/>');
$b = $dom->documentElement;
var_dump($b->hasAttributeNS('http://namespaces.molily.de/x', 'attra'));
var_dump($b->hasAttributeNS('http://namespaces.molily.de/y', 'attrb'));
var_dump($b->getAttributeNS('http://namespaces.molily.de/x', 'attra'));
var_dump($b->getAttributeNS('http://namespaces.molily.de/y', 'attrb'));
$b->setAttributeNS('http://namespaces.molily.de/x', 'attra', 'attra
neu');
$b->setAttributeNS('http://namespaces.molily.de/y', 'attrb', 'attrb
neu');
$b->setAttributeNS('http://namespaces.molily.de/x', 'attrc', 'attrc');
$b->setAttributeNS('http://namespaces.molily.de/y', 'attrd', 'attrd');
echo("\n");
var_dump($b->getAttributeNS('http://namespaces.molily.de/x', 'attra'));
var_dump($b->getAttributeNS('http://namespaces.molily.de/y', 'attrb'));
var_dump($b->getAttributeNS('http://namespaces.molily.de/x', 'attrc'));
var_dump($b->getAttributeNS('http://namespaces.molily.de/y', 'attrd'));
echo("\n");
var_dump($b->attributes->length);
echo($dom->saveXML());
?>

Expected result:
----------------
(As far as I know:)

bool(true)
bool(true)
string(5) "attra"
string(5) "attrb"

string(9) "attra neu"
string(9) "attrb neu"
string(5) "attrc"
string(5) "attrd"

int(4)
<?xml version="1.0"?>
<a xmlns="http://namespaces.molily.de/x";
xmlns:y="http://namespaces.molily.de/y"; attra="attra neu" y:attrb="attrb
neu" attrc="attrc" y:attrd="attrd"/>

Actual result:
--------------
bool(false)
bool(true)
string(0) ""
string(5) "attrb"

string(0) ""
string(9) "attrb neu"
string(0) ""
string(5) "attrd"

int(5)
<?xml version="1.0"?>
<a xmlns="http://namespaces.molily.de/x";
xmlns:y="http://namespaces.molily.de/y"; attra="attra" y:attrb="attrb neu"
y:attra="attra neu" y:attrc="attrc" y:attrd="attrd"/>

-- 
Edit bug report at http://bugs.php.net/?id=34276&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34276&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34276&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34276&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34276&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34276&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34276&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34276&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34276&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34276&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34276&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34276&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34276&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34276&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34276&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34276&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34276&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34276&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34276&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34276&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34276&r=mysqlcfg

Reply via email to