> >> Thanks for moving backward. Since iterating is now worthless i am all
for
> >> removing it completley. I mean it isn't even in the spirit of the
extension.
> >> I will sleep over this tonight and probably remove the work of another
full
> >> week too. Just because it is too complex and doesn't fit in the current
> >> scheme of SimpleXMl.

Marcus,

Ignore the user space issue for right now as I dont go into that at all. I
dont see iterators as being worthless, however there is a behavior clash
between the iterators and the arrays.
When fetching properties returning arrays for multiple elements and
returning a single sxe object for single elements (as the single sxe object
will iterate the children of the returned object). A foreach will give
different results depending upon which is returned.
$a = $foo->a;
foreach($a->b as $b) {
 ...
}

imo, the behavior should be the same regardless of what is returned. This
pretty much means generalizing things to use either arrays or iterators.

Disclaimer: Not advocating the following, just.may be a possible solution
depending upon the ultimate scope of sxe.

One nice thing is that if it were implemented as iterators, one could do:
$b = $a->b;
print $b;

as $b should be the first returned sxe object, which would have the the
iterator created (How to handle no elements would need to be determined -
either NULL or an some tpye of empty sxe object).
It could be thought of in terms of how the nodelist was
implemented in dom, yet this is much scaled down and is implemented directly
on the sxe object. This would also allow for other methods (such as
children, attrbutes, count, etc.. if any are to be implemented), to be
plugged right in, allowing for things like:
$foo->b->count(), $foo->a->children()->count(), $foo->a->attributes(),
etc...

However to implement something like above as well as to implement iterators
in sxe at all, they are going to need to point to the node proxies rather
than to the libxml nodes themselves otherwise it can be made to segfault (as
is the case today):
$foo =
simplexml_load_string('<foo><a><b><b1>b1val</b1><b2>b2val</b2></b></a></foo>
');
$a = $foo->a;
foreach($a as $b) {
 foreach($b as $subb) {
  print $subb."\n";
  unset($foo->a);
 }
}

Implementing these iterators wouldnt be as simple as they previously were,
but would offer a lot more functionality and flexibilty (interally wise)

Rob

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to