[Expat-discuss] Controlling parse process: suspend(), resume(), abort()

Karl Waclawek karl@waclawek.net
Sun Jan 20 18:03:02 2002


Would it be hard to add the following functions?
- suspend() ...suspends parsing, remembers state
- resume()  ...resumes parsing from where it was suspended
- abort()   ...cancels parsing

This looks like the concept of coroutines, and could 
have the following benefit: One could implement a "pull" based
parser on top of the "push" based model of Expat.

This has recently been chosen as Microsoft's new approach,
i.e. in XML.NET, SAX has been replaced by a pull based parser
("XMLReader").

Typical pull code would look like:
while parser.nextNode() do
begin
 //process current node
end;

It seems to me such a parser could be implemented on top
of SAX or Expat, if there was functionality as described above.
Microsoft's MSXML3 implementation has the IMXReaderControl
interface, which allows exactly that. Makes me think that
(maybe) MS's "pull" implementation is implemented on top of
their own SAX parser.

So, my question again: How hard would it be to add such
coroutine-like functionality to Expat?

Regards,

Karl