David Bertoni <[EMAIL PROTECTED]> writes:

> You can try the "progressive" parsing APIs, which report SAX events 
> incrementally.  See:
> 
> SAX2XMLReader::parseFirst()
> SAX2XMLReader::parseNext()
> 
> However, there is no control over the granularity of the parsing, so you 
> should test to make sure what it produces will work for you.

Interesting. I didn't know about this API. Looking at the documentation
it says that each call to parseNext() covers just one XML token (as
defined by the spec). Based on this it should be pretty straight-
forward to implement a custom pull parser on top of SAX2XMLReader,
e.g., something along these lines:

- Have a queue of events.
- When SAX handlers are called they add corresponding events to the queue.
- When the user calls next(), the parser check if the queue is empty.
  If it is the parser calls parseNext and the handlers add some event(s)
  to the queue with the first one then returned to the user.

Boris

-- 
Boris Kolpackov, Code Synthesis Tools   http://codesynthesis.com/~boris/blog
Open source XML data binding for C++:   http://codesynthesis.com/products/xsd
Mobile/embedded validating XML parsing: http://codesynthesis.com/products/xsde

Reply via email to