Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sax on socket  RSS feed

 
sander hautvast
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i'm trying to parse xml documents from a socket stream using SAX. Using xml files no problem. But the SAX Parser waits until EOF before raising the endDocument event (that ends parsing). But EOF is not sent over the socket until the socket is closed. Don't want to close... Any way around this??
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to wrap your data inside a protocol that has another way to signal EOF short of closing the socket (there's a simple example of a protocol in the Java Tutorial chapter on Custom Networking). Then on the client side you need to seperate your communication logic from your xml processing logic. The communication logic would convert the protocol-wrapped data into something that the sax parser can use.
I'm going to send this to the Sockets and Internet Protocols forum to see if anyone has any other bright ideas.
 
sander hautvast
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well thanks, I did just about that. wrote quite a simple xml parser that serves my needs. It reads the <roottag> and signals end when the </roottag> is found. Just curious why an open "standard" like SAX doesn't do something like this. It makes sense when reading files but not in this context. And does anyone know how EOF is implemented?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!