Streaming XML and SAX

David Megginson david at megginson.com
Wed Feb 24 14:06:14 GMT 1999


Simon St.Laurent writes:

 > Some folks on this list have suggested mechanisms like control
 > characters - ^L or ^C - to manage these streams.  While that might
 > work, it doesn't provide very much flexibility of expression.  For
 > example, it providrd no information about the relation of the
 > documents in the stream except their sequence.  In many cases,
 > relating documents in the stream to each other - or, like XP, to an
 > entirely separate stream - may be important.  The use of processing
 > instructions (or, if you want to be grouchy, markup that uses a
 > PI-like syntax) seems appropriate.

Layering doesn't work unless each layer is as simple as possible:

1. Use a non-XML mechanism for separating XML packets -- that way,
   there's not a tight dependency between the stream-handler and the
   parser (the stream handler knows the bounds of each packet without
   doing any XML parsing).

2. Separate information about the packages from the packets
   themselves.  The information could be linear, or it could itself be 
   XML packets of a different sort.  You should not have to parse an
   entire packet to know its sequencing, etc.

3. Don't require the main packet to be XML -- it might often make
   sense to send binary information such as video and audio clips as
   well (of course, it will probably have to be base64 encoded, but
   that's a separate issue).

Putting a PI in the XML packet itself seems a little awkward to me.
I'd rather have something like the following:

^C
Packet 1.0
Seq=345
Stream=24232
^L
<packet xmlns="http://www.streaming.com/ns/">
<x>yyy</x>
</packet>
^C

or, if you prefer

^C
<packet-info version="1.0" xmlns="http://www.streaming.com/ns/">
<seq>345</seq>
<stream>24232</stream>
</packet-info>
^L
<packet xmlns="http://www.streaming.com/ns/">
<x>yyy</x>
</packet>
^C

That way, the main socket layer can just scan for ^C and ^L and then
pass the appropriate chunks (the packet info and the packet proper)
off to more specialised layers for processing.


All the best,


David

-- 
David Megginson                 david at megginson.com
           http://www.megginson.com/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list