[xml] sax2 interface and parsing on the fly



hi,
for my sparetime project of the last 0.75 year i was building a XMPP 
lib for usage on different platforms. it is not finished yet but 
nearly done.

if you don't know about xmpp/jabber, please read this to understand 
my problem:

XMPP is the same as Jabber(www.jabber.org). This is an instant 
messenging and presence protocol using xml.
If connected to a XMPP server there is an IN stream and an OUT stream 
that is each time like a XML document that will end ONLY if the 
stream ends:
[connecting to server]
<stream:stream>
    <message to="blah blub com">text</message>
        ...
</stream:stream>
[connection closed]


Problem:
For the stream analysation I wrote some kind of stream readed that is 
in fact a sax interface that i randomly fed with new buffer 
containing the new received elements (<message/> <presence/>)
yesterday i downloaded a new build of libxml2 (windows binaries of 
zlatkovic).
I noticed that my lib did not behave as expected.
in fact the startElement() function is not called anymore.
whatever when i disconnect from xmpp server (the server sends a 
</stream:stream> then!) the function gets called and all the data is 
parsed then...
Therefor my current code seems not to execute parsing anymore. i 
don't know why but there might be two explainations:

1. you mutated the libxml2 sax2 parser to something like xmlreader 
(and this can not parse xml on the fly anymore)
or
2. you changed the behaviour of some function that in earlier version 
caused the parser to parse. Probably xmlParseChunk()

It would be great if you can help me and it would be even more great 
if you wont tell me that libxml2 (sax2) will not be able to parse on 
the fly in future anymore.

best regards
Edrin

the code for reading the stream follows:

        if(iRecv > 0)
        {               if(m_ptxmlParserCtx == 0)
                {
                        wxLogDebug(wxT("XCD: xs_StreamReader::StreamBuffer_Add() - New 
context buffer required. Parsing..."));

                        //new parser ctx buffer required...
                        m_ptxmlParserCtx = xmlCreatePushParserCtxt(&x_SAXHandlerStruct,
                                                                                                              
  this,
                                                                                                              
  recvBuff,
                                                                                                              
  4,
                                                                                                              
  0);


                        if(m_ptxmlParserCtx != 0)
                        {
                                if(xmlParseChunk(m_ptxmlParserCtx, recvBuff+4, iRecv-4, 0) == 0)
                                {
                                        wxLogDebug(wxT("XCD: xs_StreamReader::StreamBuffer_Add() - 
ParsingSuccess 0!"));
                                        bReturn = true;
                                }
                                else
                                {
                                        wxLogDebug(wxT("XCD: xs_StreamReader::StreamBuffer_Add() - 
ParsingError 0!"));                                     
                                        if(m_ptxcdXMLSessionOwner != 0)
                                                m_ptxcdXMLSessionOwner->readerOnStream_Error();
                                }
                        }
                        else
                                wxLogDebug(wxT("XCD: xs_StreamReader::StreamBuffer_Add() - Could 
not create PushParserCtxt!"));
                        

                }
                else
                {
                        wxLogDebug(wxT("XCD: xs_StreamReader::StreamBuffer_Add() - 
Parsing..."));

                    if(xmlParseChunk(m_ptxmlParserCtx, recvBuff, iRecv, 0) == 0)
                        {
                                wxLogDebug(wxT("XCD: xs_StreamReader::StreamBuffer_Add() - 
ParsingSuccess 1!"));
                                bReturn = true;                         
                        }
                        else 
                        {
                                wxLogDebug(wxT("XCD: xs_StreamReader::StreamBuffer_Add() - 
ParsingError 1!"));
                                if(m_ptxcdXMLSessionOwner != 0)
                                        m_ptxcdXMLSessionOwner->readerOnStream_Error();                       
  
                        }
                }

        }





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]