Re: [PHP-XML-DEV] Re: [PHP] PHP5: ext/dom - set namespace of node manually
[email protected] (Christian Stocker) Mon, 16 Feb 2004 12:25:05 +0100
| Newsgroups | php.general,php.xml.dev |
|---|---|
| Message-ID | <[email protected]> |
On 2/16/04 12:07 PM, Rob Richards wrote:
>>Porting the setNamespace function to PHP5 would be nice. Another solution
>>could be the possibility to append a namespace-node (is the
>>domnamespacenode class currently used by any functions?) or the
>>setAttribute checks wether some "xmlns"/"xmlns:" attribute is set and
>>updates namespaceUri itself... would be more W3C standard compliant.
>
>
> The namespace node isnt really used with any functions. It is also a
> "special" node as its not a standard node type in libxml.
> Via the specs, it doesnt really exist, but it can be returned via xpath,
> which is why dom manipulates the libxml namespace into a returnable type,
> which a few of the properties are allowed to work with it (otherwise either
> dom would either have to prevent xpath from returning it or let the system
> crash when its returned - neither of these options was acceptable - thus
> this special node).
>
> As far as setAttributeNS goes. This function actually does do checks,
> however it doesnt put the element into the current namespace (which possibly
> may be a logic bug - namespaces internally are so damned confusing).
>
> Using the syntax:
>
> $node->setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:b",
> "http://www.somedomain.de/");
>
> This sets the definition on the element but doesnt put that node into the
> namespace, it just puts the namespace into the scope of the node, so that
> elements added with createelementns and appended as children of $node can be
> placed within the namespace and would be prefixed with "b".
>
> Now here is the question, if a namespace is not associated on the element at
> that point, should the above set the element into the new namespace? (Easy
> enough to implement, but really have no clue if this is the proper logic or
> not). Any namespace gurus around here?
IMHO, that would be very confusing.
I liked the idea by vivian with a third optional namespaceURI argument
for the element object, so that at least you can use your own extended
classes for that.
And maybe we still need a ->setNamespaceURI method, even if W3C didnt
think of that ;)
chregu
>
> Rob
>
--
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71
http://www.bitflux.ch | [email protected] | gnupg-keyid 0x5CE1DECB