Streaming XML and SAX

David Megginson david at
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:

Packet 1.0
<packet xmlns="">

or, if you prefer

<packet-info version="1.0" xmlns="">
<packet xmlns="">

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 Megginson                 david at

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

More information about the Xml-dev mailing list