The loop can be stopped when we temporary run out of FO tree nodes and restarted again when new nodes has been added. I suppose that the FO tree can then be viewed as a stream of FO nodes.
This model probably works fine if you never need to look ahead, but there
are numerous examples (well discussed in the archives) where one does need
to do that, the most obvious being automatic table layout. Peter's solution
to that is pull parsing, which probably works, but forces an intermingling
of interests that I need to avoid. My solution is to serialize the FOTree as
Did you notice that if a FOTree (or a fragment of it) is serialized to a preorder sequential representation with end markers, the preorder, postorder and child events can be fired directly from the input stream?
Which is what Defoe does. Now let go of the notion of "firing events", and we are in agreement. The SAX model is not relevant once the basic parsing is done. With a full-fledged stream parser, it won't be relevant at all.
IOW the event based layout can work both of a normal parent/children linked tree and a sequential tree.Peter