Quick stupid SAX question from someone returning to Sweet Mother Java
Ladies and Gents,
A career move about 4 years ago took me out of the realm of Java programming. A more recent move brought me back, and I find myself trying to get reacquainted with stuff I vaguely remember. I have a quick question regarding common techniques for parsing streaming XML. (and yes, I know I could probably find the answer with a web search, but I tend to find things after after I've posted stupid questions to forums. Such is the way of the Universe).
Anyway, my issue: I'm trying to figure out the best way to do dynamic parsing of a streaming XML input. Basically, there's an application doing logging in XML to either a socket or a file; my Java application has to be able to parse and display the streaming output in some meaningful manner in realtime.
My question is: what are the common ways of dealing with streaming XML, where the entire document isn't fully formed as it's being parsed (and may never be fully formed, if the stream never ends). The approach I'm taking right now is a SAX parser, with a handler that's taking the parsed elements and building a data structure out of the output. Basic stuff. The problem I run into is when I'm trying to parse a streaming file: the file EOF keeps causing the parser to throw an malformed xml exception, due to the fact that the xml stream isn't done. I haven't begun work on the socket-based input, so I'm not sure if there are any hurdles there.
I have to believe this is a problem that's been solved. Can anyone point me to examples of prior art for something like this?
Thanks in advance.
I have to believe