Re: [PHP-DEV] Making SimpleXML more useful

2011-04-30 Thread David Zülke
On 30.04.2011, at 22:05, Ben Schmidt wrote: > This adds a certain ambiguity to document creation if it is used, but it > does add functionality not currently there. I guess it's only worth > doing if there are specs out there in the wild that (wrongly IMHO) > require "unqualified" names in XMLName

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-30 Thread Ben Schmidt
Again, xmlns="" puts an element in no namespace. That already works in SimpleXML. There is no issue here that needs fixing. IIUC, the OP doesn't want the element to be in no namespace, but wants it to be in the default namespace, but unprefixed. I have already laid out my reasons for believing

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-30 Thread David Zülke
On 29.04.2011, at 09:44, Tom Samplonius wrote: > >> While I think this would make SimpleXML more stupid, not less, as it >> seems >> braindead to me to allow users to create documents ambiguously and/or >> which >> essentially violate the XML namespace spec, I think the way to do > > Allowing c

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-29 Thread Tom Samplonius
> > $sxe->addChild('child', 123); # Adds element with namespace > > inherited from the parent > > $sxe->addChild('child', 123, 'urn:somenamespace'); # Adds child > > with specified namespace > > $sxe->addChild('child', 123, -1); # Adds child with no namespace > > qualification > > Again, there is

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-29 Thread Rob Richards
On 4/29/11 3:44 AM, Tom Samplonius wrote: While I think this would make SimpleXML more stupid, not less, as it seems braindead to me to allow users to create documents ambiguously and/or which essentially violate the XML namespace spec, I think the way to do Allowing child elements to be unqu

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-29 Thread Ben Schmidt
While I think this would make SimpleXML more stupid, not less, as it seems braindead to me to allow users to create documents ambiguously and/or which essentially violate the XML namespace spec, I think the way to do Allowing child elements to be unqualified is neither braindead or ambiguous. A

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-29 Thread Tom Samplonius
> While I think this would make SimpleXML more stupid, not less, as it > seems > braindead to me to allow users to create documents ambiguously and/or > which > essentially violate the XML namespace spec, I think the way to do Allowing child elements to be unqualified is neither braindead or am

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-28 Thread Ben Schmidt
While I think this would make SimpleXML more stupid, not less, as it seems braindead to me to allow users to create documents ambiguously and/or which essentially violate the XML namespace spec, I think the way to do this would be to define a magic constant and use that. E.g. const SIMPLEXML_D

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-28 Thread Tom Samplonius
> That patch is not a good idea. > > Assume you have this situation: > > > > > > > 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

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-27 Thread Rob Richards
On 4/27/11 1:59 AM, Tom Samplonius wrote: - Original Message - Looking at this in more detail...I don't think there's a bug here, or a patch required. ... problem for me, as I have an XML schema that specifies that the child elements must not namespace qualified. Is this possible in

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-27 Thread Ben Schmidt
problem for me, as I have an XML schema that specifies that the child elements must not namespace qualified. Is this possible in an XML schema? I don't know much about schemas, but ... Absolutely, if the XML schema has the "elementFormDefault" attribute set to "unqualified", the child element

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-26 Thread David Zülke
That patch is not a good idea. Assume you have this situation: Adding a child "baz" to bar and have it default to no namespace prefix would result in this: Now would be in the namespace "urn:lol". Keep in mind that xmlns="" is, as per the XML spec, a perfectly valid way to

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-26 Thread Tom Samplonius
- Original Message - > Looking at this in more detail...I don't think there's a bug here, or > a > patch required. ... > > problem for me, as I have an XML schema that specifies that the > > child > > elements must not namespace qualified. > Is this possible in an XML schema? I don't k

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-26 Thread Ben Schmidt
Looking at this in more detail...I don't think there's a bug here, or a patch required. It is not possible to use SimpleXML to add a child element without a namespace prefix to a parent element that has a namespace element. Instead, the child element inherits the namespace prefix of the parent.

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-26 Thread Ben Schmidt
I would expect the children() method to return just the last two elements of your input XML: http://localhost/a"; xmlns:ns="http://localhost/a";> as the last two elements are the only ones in the 'http://localhost/a' namespace. No, every element in the document is in the same namespace.

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-26 Thread Michael Shadle
Personally I'd love to see an option to make it spit out an array. Just like te second parameter in json_decode() Since array keys can include colons prefix work would also be easier. Then something akin to array2XML() to spit it back out. On Apr 26, 2011, at 7:43 PM, Tom Samplonius wrote: >

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-26 Thread Tom Samplonius
- Original Message - > A similar problem regarding attributes, that got classified as a doc > bug, but I > don't think is one: http://bugs.php.net/42083 > If you're fishing around that area of the code, though, perhaps it is > quite > obvious to you where/how a patch should be made?

Re: [PHP-DEV] Making SimpleXML more useful

2011-04-26 Thread Ben Schmidt
A similar problem regarding attributes, that got classified as a doc bug, but I don't think is one: http://bugs.php.net/42083 If you're fishing around that area of the code, though, perhaps it is quite obvious to you where/how a patch should be made? Ben. On 27/04/11 9:23 AM, Tom Samploniu

[PHP-DEV] Making SimpleXML more useful

2011-04-26 Thread Tom Samplonius
It is not possible to use SimpleXML to add a child element without a namespace prefix to a parent element that has a namespace element. Instead, the child element inherits the namespace prefix of the parent. So this XML fragment: abc is impossible to construct with SimpleXML. The Simp