#47747 [Bgs]: DOMAttr returns incomplete attribute name
| From: | mpeters at mac dot com | Date: | Sun, 22 Mar 2009 20:28:46 +0000 |
| Subject: | #47747 [Bgs]: DOMAttr returns incomplete attribute name | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-135003@lists.php.net to get a copy of this message | ||
ID: 47747
User updated by: mpeters at mac dot com
Reported By: mpeters at mac dot com
Status: Bogus
Bug Type: DOM XML related
Operating System: CentOS 5.2
PHP Version: 5.2.9
New Comment:
Not bogus -
There is no way via DOMAttr to even know that an attribute name is part
of a nanespace because DOMAttr->name DROPS the namespace and DOMAttr
does not provide a facility by which to even know it was ever there.
Previous Comments:
------------------------------------------------------------------------
[2009-03-22 20:20:10] chregu@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Forgot to set it Bogus :)
------------------------------------------------------------------------
[2009-03-22 20:15:23] chregu@php.net
you have to use the NS aware functions like setAttributeNS to get the
correct behaivour, eg:
$tag-
>setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:lang","en");
------------------------------------------------------------------------
[2009-03-22 12:54:22] mpeters at mac dot com
Full php demonstration -
The code that demonstrates:
http://www.clfsrpm.net/bugs/domattr.phps
Execution of code:
http://www.clfsrpm.net/bugs/domattr.php
------------------------------------------------------------------------
[2009-03-22 11:24:30] mpeters at mac dot com
Description:
------------
I'm using php 5.2.5 - upgrading is not possible. Sorry.
DOMattr->name does not include anything before a : nor provide a way to
access what was before a : in an attribute name.
Reproduce code:
---------------
Let's say $node refers to the following node -
<something xml:lang="en" foo="alpha" bar="beta" />
$attributes = $node->attributes;
foreach ($attributes as attribute) {
print ($attribute->name . "\n");
}
will result in
lang
foo
bar
notice the xml: is missing from before the lang.
DOMAttr provides no way to know that lang had a xml: before it.
However -
$node->hasAttribute('lang') is false while
$node->hasAttribute('xml:lang') is true
Expected result:
----------------
Either $DOMAttr->name
needs to provide the full attribute name including namespace or provide
a way to know what (if any) the namespace for the attribute name is.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47747&edit=1