[jdev] Re: Re: Re: Parsing XMPP/Jabber protocol

Heiner Wolf wolf at bluehands.de
Tue Jan 4 08:22:52 CST 2005


>On Tue, 4 Jan 2005 00:13, Heiner Wolf wrote:
>> Hi,
>>
>> >        String s1 = "<?xml version=\"1.0\"?><str";
>> >        String s2 = "eam><element>qwe</element></stream>";
>>
>> I wonder who would ever be interested in getting notification of a
>> partial <stream> tag. This is a weird case and I suppose applications
>> have no problem waiting for the "eam>".
>
>The notification would be unnecessary.  The actual problem is that if you have 
>to wait for the "eam>", you tie up a thread in your application which is 
>handling the wait().  So whereas it's perfectly fine for a client connected 
>to a single server, or even a component, a client which handled multiple 
>connections would need one thread open per connection.  A server... well, 
>that would be nuts.  1,000 connected clients and you already have 1,000 
>threads open, which is less than practical in most cases. :-)
>
>A parser which can parse only what is available can bypass these problems as 
>you can have one thread using select() and handling every socket at the same 
>time.

Yes, :-) 
I am not sure what we are talking about. Sure, you would use a single thread and select. Sure, a SAX parser must be (and usually is) able to eat what it gets and return callbacks whenever it discovers a state. That's what expat does. Nobody will wait for the "eam>", The SAX parser buffers the "<str" until it gets "eam>", enters the startElement() state and notifies. 

What I did was to complain about SAX in general. While SAX parsers work great supporting a single thread server architecture, they still miss a layer that is necessary for the app programmer. That would be the "Fragment API for XML". My comment was targeted at the noob Jabber programmers who are listening this thread trying to find out how to parse the damn Jabber protocol that "does not come back until the connection closes" :-) 

Regards
hw
--
Dr. Klaus H. Wolf
bluehands GmbH & Co.mmunication KG
http://www.bluehands.de/people/hw
+49 (0721) 16108 75
--
Jabber enabled Virtual Presence on the Web: http://www.lluna.de/
Open Source Future History: http://www.galactic-developments.com/



More information about the JDev mailing list