My solution would be to tell the parser to read from an in-memory stream 
acting as a FIFO buffer, and run it in its own thread; then push data into 
that stream from the communications thread as it becomes available. 

Of course the hard thing is going to be carrying this handshaking through 
to the application consuming the data, if it isn't driven completely by 
the SAX stream; you may need to design an in-memory document model that 
can be built incrementally and knows how to wait for more parsing if the 
requested subtree hasn't yet arrived. We did something along those lines 
for incremental DTM construction in Xalan, though there it was a matter of 
the model wanting to control the parser rather than vice versa.

______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
http://www.ovff.org/pegasus/songs/threes-rev-11.html)

Reply via email to