[JDEV] Jabber documentation question; XML parsing worries; and ease of d evelopment
Justin
infiniti at affinix.com
Mon May 20 12:05:50 CDT 2002
On Monday 20 May 2002 08:33, Gallo, Felix S. wrote:
> ...it's not at all clear when a good time to call parse() is. It looks
> like in order
> to deal with XML streams, one would essentially have to pre-parse the XML
> stream to find the closing tag's last character, bundle that up into a
> buffer and
> parse that, and then start some more. Is that accurate? If not, where am
> I being
> dumb? If so, isn't that annoyingly painful?
Your XML library needs to support on-the-fly parsing. I use the Qt SAX parser
in my client (Psi), and it treats the XML as a byte stream. This makes TCP
packet-boundaries irrelevent. The parser keeps track of all state between
calls, and only notifies my program when it has received enough data to be
able to tell me something.
After the <stream> tag, Jabber XML chunks all begin and end at the same depth
level. What Psi does is use the Qt DOM classes to store the XML it receives
from the SAX parser. Once a complete chunk is forumlated (ie, depth returns
to normal), then the DOM structure is passed to the application.
In my program, this class is named "JabStream" and is probably the only part
of the application that I am (almost) fully satisfied with. Its entire
purpose in life is to send/receive DOM structures and to report <stream>
errors.
> 3. This is more a plaintive bleat than a question: why are there about ten
> different 60% complete C/C++ libraries, dammit? :)
http://webcvs.kde.org/cgi-bin/cvsweb.cgi/kdenonbeta/psi/libpsi/src/
And yet another :) Mine still needs a few more days of programming attention,
and then some documentation before it is ready (although as you can see the
age of the files are already 4 weeks, who has time these days?). It is
dependent on Qt though, so that may or may not be useful to you. Of course,
you can always read the header files and draw some ideas of your own.
I think people keep starting new libraries because the ones available are
incomplete. When I started working with Jabber, I first looked around for a
library. The best candidate was jabberoo, but it didn't even have an
official release yet.
I'm glad I started my own though, as I think I came up with some pretty good
ideas. It is also Qt-specific, which means it is very easy to use and
portable (assuming you are using Qt for portability), but it is probably not
very useful in a non-Qt program (but then, who needs another plain C++ Jabber
library? I say finish jabberoo for that).
Good luck,
-Justin
More information about the JDev
mailing list