Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XML as a stream protocol.

Reply
Thread Tools

XML as a stream protocol.

 
 
jbi130@yahoo.com
Guest
Posts: n/a
 
      02-26-2004
Hello,

We're redesigning a custom binary application protocol built on TCP
and I thought we should evaluate some XML options. I have a few
questions on how to best handle a stream of XML data.

The first option I looked at is similar to XMPP. After looking at
XMPP we may be able to use some of it, but since we'd end up writing
our own implementation we are not worried about sticking to a spec.
So, our first option would use a complete document in each direction
as the whole connection.. eg)

<connection>
<message>
...
</message>
...
</connection>
close socket.

What is the best parse model for this? Because the <messages> are
never going to be that big, DOM would be nice b/c it seems simpler to
code. But can DOM be applied to just a section of the whole document?
Is our only (standard) option here to use SAX?

The other option I thought of is to add some framing so each message
is its own document..

NUMBER_OF_BYTES\r\n
<message>
...
</message>

Where NUMBER_OF_BYTES is the length of the following "document" so it
can be read in from the socket then passed to a DOM parser.

So what is the better way? What works better with the available XML
parsers? Our applications are writtin in Python, C and Java.

Sorry if this is all basic, but my XML experience is not about 2 days
old.

Thanks.
 
Reply With Quote
 
 
 
 
Patrick TJ McPhee
Guest
Posts: n/a
 
      02-27-2004
In article <(E-Mail Removed)>, <(E-Mail Removed)> wrote:

[...]

% So, our first option would use a complete document in each direction
% as the whole connection.. eg)

[...]

% What is the best parse model for this? Because the <messages> are
% never going to be that big, DOM would be nice b/c it seems simpler to
% code. But can DOM be applied to just a section of the whole document?

DOM parses the entire document before giving the tree back to you.

% Is our only (standard) option here to use SAX?

Standard is a relative term, but yes.


% The other option I thought of is to add some framing so each message
% is its own document..

% NUMBER_OF_BYTES\r\n
% <message>
% ...
% </message>

I like this approach better. Each message really _is_ its own document,
so it ought to be represented as such.

% So what is the better way? What works better with the available XML
% parsers? Our applications are writtin in Python, C and Java.

Using python, you'll probably want to use libxml as the parser, and you
might as well also use it for C. This approach will work well with
the parser -- you hand it a buffer with the document in it, and it
hands you a tree back. With java, there's more standardisation, and
any parser ought to handle it OK.

--

Patrick TJ McPhee
East York Canada
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert DVD with subtitle stream to DivX with same subtitle stream(selectable) malise Software 1 04-17-2007 09:15 AM
what is the different between byte stream and character stream? dolphin Java 6 03-18-2007 01:58 PM
get stream mode flags from an opened stream Alexander Korsunsky C++ 1 02-17-2007 10:38 AM
How to GET multi-word input from a *file* stream as opposed to a *console* stream? sherifffruitfly@gmail.com C++ 9 04-27-2006 04:14 PM
Doing readline in a thread from a popen4('rsync ...') stream blocks when the stream ends. Rasmusson, Lars Python 1 04-30-2004 08:10 AM



Advertisments