You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Tony Cheung <dr...@asiayeah.com> on 2001/05/03 03:43:50 UTC
Inputstream buffering by Xerces
Hi All,
I am having a problem with Xerces parsing a stream from a socket.
Although I am getting messages parsed as data comes in on the socket,
there is a buffering going on somewhere, which delays the XML until
another after more text arrives. This will not work for my application,
where 'packets' of XML data define events.
Can anyone offer me any advice, or even point out where to start
looking?
Thanks a lot!
Tony Cheung
Re: Inputstream buffering by Xerces (possible bug!)
Posted by Tony Cheung <dr...@asiayeah.com>.
Hi All,
I have found the possible solutions in
http://xml.apache.org/xerces-j/faq-write.html#faq-11.
I have tried it and I found out that it still has a buffering of 2
characters!
I construct InputSource as new InputSource(new BufferedReader(new
InputStreamReader(inputStream))). I have found out that "int read(char[]
cbuf, int off, int len)" is being called with len=2. Callbacks are
generated 2 characters lag behind the XML received.
e.g. <MSG>Hello World</MSG><MSG>
^ callbacks for </MSG> are generated here
In my case, if the last XML received is <MSG>...</MSG>, and there's nothing
more XML coming, the </MSG> callback is never generated until the socket is
closed.
My solution right now is to insert 2 space characters, like this,
<MSG>Hello World</MSG> <MSG>Hello World 2</MSG>
Any idea on how to solve this? Or it is a bug?
Thanks a lot!
Tony Cheung
Tony Cheung wrote:
> Hi All,
>
> I am having a problem with Xerces parsing a stream from a socket.
> Although I am getting messages parsed as data comes in on the socket,
> there is a buffering going on somewhere, which delays the XML until
> another after more text arrives. This will not work for my application,
> where 'packets' of XML data define events.
>
> Can anyone offer me any advice, or even point out where to start
> looking?
>
> Thanks a lot!
>
> Tony Cheung