Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

parsing an xml document chunk by chunk

843834Mar 17 2009 — edited Mar 17 2009
Hi,
I have to parse a xml document, that actually is received in many chunks, and unfortunately I have to parse it chunk by chunk and not at the end, when I've received all the chunks.
I was thinking at a SAX parser instead of StAX, since I have to push the parser when i receive the data.
I was also thinking at an OutputStream where to write the chunks when I receive them, and pipe the OutputStream to an InputStream to be passed to the parser.
But I think there is no way to let the parser read from the InputStream in the same thread. So I have to create a thread for every receiving document, but ince the program may actually receive many different documents at the same time and that chunks may be received with long delays I have to create many threads that will be mainly idle while waiting for the chunks.
Is there a way to bypass the piped input and output streams and directly call the parser on a single chunk when it is received?
In other words, is there a way to call in the same thread a parse only for a xml document chunk, and call it many times until the document is completely received?
thank you very much,
marco
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2009
Added on Mar 17 2009
9 comments
597 views