> That patch is not a good idea. > > Assume you have this situation: > > <foo xmlns="urn:lol"> > <x:bar xmlns:x="urn:hai"> > </x:bar> > </foo> > > Adding a child "baz" to bar and have it default to no namespace
Actually, my patch wouldn't change the default action of addChild(). It would still inherit the namespace qualification of the parent by default. > prefix would result in this: > > <foo xmlns="urn:lol"> > <x:bar xmlns:x="urn:hai"> > <baz /> > </x:bar> > </foo> > > Now <baz /> would be in the namespace "urn:lol". I don't see why this is a problem? I actually need to be able to add unqualified child elements. > Keep in mind that xmlns="" is, as per the XML spec, a perfectly valid > way to reset the namespace of an element. Right now, the behavior of addChild() is: * $namespace is unspecified --> inherit from parent * $namespace is specified --> use that as the namespace for the element (and this could be "") I need a third option, where I can add an element that is unqualified. There really are just two possible choices, either add a new "value" of $namespace (like (int) 0) that requests this behavior. Or, use some sort of magic namespace value (like "unqualified") to specify an unqualified element. Is there any opinion on which is better for addChild()? ... > SimpleXML is supposed to be simple (I find it more stupid than simple, but > that's my personal opinion). > I guess that's why it, by default, inherits the parent namespace The only way to make it less stupid, is to start fixing it. Tom -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php