The parser will always have to do this, because your data might be a
multiple of its internal buffer size.  In that case, you'll still have to
do your "gross hack", which doesn't really seem that gross a hack to me.

Dave



                                                                                       
        
                    Norbert Kiesel                                                     
        
                    <nkiesel@tbdnet        To:     [EMAIL PROTECTED]         
        
                    works.com>             cc:     (bcc: David N Bertoni/CAM/Lotus)    
        
                                           Subject:     parser trying to read twice    
        
                    07/24/2001                                                         
        
                    02:12 PM                                                           
        
                    Please respond                                                     
        
                    to xerces-c-dev                                                    
        
                                                                                       
        
                                                                                       
        




Hi,

I'm using Xerces (currently 1.4) to parse XML sent over a socket
connection.  I've written a BinSockInputStream class which is derived
from InputStream to feed the data into the parser.  In order to send
more than one XML "file" over the same socket connection, I send a
special illegal character (Ctrl-L) at the end of each XML "file" which
is recognized (and removed) by BinSockInputStream.

Everything works beautifully besides one thing: the parser always
calls BinSockInputStream::readBytes a second time after receiving the
complete XML data. Example: if I get an XML which is shorter than the size
of the buffer passed to readBytes, I fill the buffer with the complete
XML file.  Then, the parse function calls readBytes again.  At this
point, I have no more data to return.

My first implementation just tried to read more data from the socket
(and thus was blocked if this was the last XML "file").  Now I have a
stupid flag in BinSockInputStream which just retuns 0 on every second
invocation.  This seems to work, but is of course a gross hack.

So finally my question: -)
  What do I have to do to tell the parser that it has got everything
  and should not try to read more characters?

--nk

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to