Stopping XML parsing in mid-stream?

Michael Chang <[email protected]>
Newsgroups gmane.text.xml.sax.general
Message-ID <[email protected]>
Hi, list.


I've got a problem.  Here's the situation:  My application uses an 
SSLSocket to read XML data from a server that sends a new XML document (?) 
once per second.  By "XML document," I mean that an entirely
new "<?xml version='1.0' ?><nodes>.....</nodes>" chunk is sent to my 
client application once per second.  The problem that I'm having is that, 
when I hand my InputStream object to my SAXParser.parse() method, parse() 
never returns.  The only way I can get it to return is if I tell the 
server to send only one chunk and then close the connection.  From this, I 
assume that parse() returns because it has seen an EOF (End Of File), 
though I might be wrong.

So, essentially, I need a way to get parse() to return after it has seen a 
closing root node.

As an experiment, I've tried grabbing just one chunk by reading the XML 
data into a string and then doing the following:
  foo.parse(new InputSource(new StringReader(somexmlstring)));
However, a SAXParseException is thrown; the error being that it found a 
null byte within the string (which is obviously not valid XML).  So, I've 
ditched the latter idea due to both the null-byte error and the overall 
inelegance of it.  I'd really rather just hand my InputStream to parse()
and let it do the rest.


Does anyone have any idea about how to get parse() to stop parsing the 
stream after seeing the closing root node?  I've implemented all of the 
interfaces that DefaultHandler provides; however, none of those callbacks 
get invoked, so I'm assuming that the processing does not stop until it 
has seen the end of the stream (which, in my case, will never happen, 
since the stream is neverending).


Help!!



TIA,
Michael







-- 
/* BEGIN SIG 
*
* "Afraid of change, afraid of staying the same,
*  when temptation calls, we just look away."
*  - Barenaked Ladies
*
* "He started writing in mirror writing, 'Help! I'm
*  trapped behind the world.'"
*  - New York State Journal of Medicine
*
*-----------------------------
* Michael Chang
* [email protected]
* http://www.syndetic.org/
*/



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
List: [email protected]
See:  http://www.saxproject.org
https://lists.sourceforge.net/lists/listinfo/sax-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.