SAX and Threads and Rock'n'roll.
Can anyone help me with a Java/XML parsing problem?
The way the SAXParser works, is it sits around blocking on an InputStream. This isn't a particularly good match for non-blocking IO, as you end up wasting a thread for each stream you're parsing. What I'd like is a SAX parser that works the other way round, by letting me push the raw data into it, chunk by chunk.
Does such a beast already exist? Am I missing something in the standard API that I wouldn't be if I'd got more sleep last night? If not, I expect it'd be easy for me to hack Xerces to work the way I want it to, but I dislike reinventing the wheel.
I'm not aware of any XML parser using non blocking IO. Typically XML documents are not that big so you could use non-blocking IO to load the text into RAM then when the buffer is fully loaded, parse it in one go using SAX without any IO blocknig.
There are pull parsers like StAX and XPP, where you pull information out of the XML parser as you need it, rather than SAX which pushes it into your handler. Though both approaches currently use blocking IO. So using non-blocking IO outside of the XML parsing makes the most sense I think.