XML as a stream protocol.

Discussion in 'XML' started by jbi130@yahoo.com, Feb 26, 2004.

  1. Guest

    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.
     
    , Feb 26, 2004
    #1
    1. Advertising

  2. In article <>, <> 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
     
    Patrick TJ McPhee, Feb 27, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rasmusson, Lars
    Replies:
    1
    Views:
    764
    popov
    Apr 30, 2004
  2. Replies:
    9
    Views:
    644
    Alex Buell
    Apr 27, 2006
  3. Alexander Korsunsky

    get stream mode flags from an opened stream

    Alexander Korsunsky, Feb 17, 2007, in forum: C++
    Replies:
    1
    Views:
    457
    John Harrison
    Feb 17, 2007
  4. dolphin
    Replies:
    6
    Views:
    558
    Thomas Fritsch
    Mar 18, 2007
  5. mrstephengross
    Replies:
    3
    Views:
    399
    James Kanze
    May 10, 2007
Loading...

Share This Page