[Twisted-Python] xmlstream problem

Gabriel Rossetti mailing_lists at evotex.ch
Tue May 20 11:50:41 EDT 2008


Hello,

I am using xmlstream.XmlStream to process...XML streams :-)
I'm having a bit of a problem, I have a client and a server, both 
protocols inherit from xmlstream.XmlStream. When the client sends 4 
messages, one after another, I get a parse error. I debugged my program, 
and the buffer the expat parser is given contains in effect, 4 messages 
consecutively like so :

str: 
<message>...</message><message>...</message><message>...</message><message>...</message>

(I replaced the child elements with "..." for your reading enjoyment)

and I get this Exception when debugging (otherwise it stays hidden) :

ExpatError: junk after document element: line 1, column 196

now column 196 is the end of the 1st msg's root element, I think it 
doesn't like the next message being right after the first. I did 
override xmlstream.XmlStream.onDocumentEnd()
because I didn't want it to close the connection in between messages, 
but in my method I told it to initialize the stream using :

self._initializeStream()

I did this since I noticed that closing the connection forces a new 
parser to be created when the previous statement is called. The reason I 
don't want the connection to be closed is that I'd like a persistent 
connection to be held.

Does anyone know how to either have the messages given to the parser as 
separate messages so that it doesn't freak out?

Thank you,
Gabriel






More information about the Twisted-Python mailing list