Separating documents in a stream

John Tigue john.tigue at
Sun Nov 14 06:30:13 GMT 1999

Richard Anderson (rja at wrote:
> Provided the xml pi is _always_ used that can be used 
> as the separator and seems the cleanest approach to me.
> ----- Original Message -----
> From: David Megginson <david at>
> > kragen at (Kragen Sitaker) writes:
> >
> > > One protocol I remember reading about uses ]]>]]> to 
> > > separate XML documents, since that's a sequence that 
> > > can't occur inside a legal XML document.
> >
> > True, but ^L (formfeed) is not allowed within an XML 
> > document either -- it's still my favourite as a separator.

I'd consider using multipart MIME to solve the problem 
of seperating documents in a stream.

Here's the spec:
Borenstein, N. and Freed, N., 
"MIME (Multipurpose Internet Mail Extensions): Mechanisms for
Specifying and Describing the Format of Internet Message Bodies"

Multiparting is well defined, well tested, and there exists free 
compliant software. Also by using technology which is orthogonal 
to XML, implementation code can be re-used.

Here's an example of what multipart looks like:

MIME-Version: 1.0
Content-Type: multipart/digest; boundary="---- next message ----"

------ next message ----

...document 1 goes here ...

------ next message ----

...document 2 goes here...

------ next message ------

There's even a sub-type 'multipart/related' which works well for 
aggregate documents with interlinked parts and a defined root
entity (for example, for HTML email the root is the HTML document 
and it links to the non-root images). multipart/related maintains
the internal links during transfer. XML document are a good
candidate for multipart/related.

Here's the multipart/related spec:
Levinson, E.,
"The MIME Multipart/Related Content-type"

Here's a modified example from the spec. In this example there
are 3 parts: 1 HTML-like doc and 2 JPEGs.

Content-Type: Multipart/Related; 
     start="950118.AEBH at"

Content-Type: text/xml; charset=iso-8859-1;
     declaration="950118.AEB0 at"
Content-ID: 950118.AEBH at
Content-Description: Document

This picture was taken by an automatic camera mounted ...
<image file="cid:950118.AECB at" />
 Now this is an enlargement of the area ...
<image file="cid:950118:AFDH at" />
Content-Type: image/jpeg
Content-ID: 950118.AFDH at
Content-Transfer-Encoding: BASE64
Content-Description: Picture A

[encoded jpeg image]
Content-Type: image/jpeg
Content-ID: 950118.AECB at
Content-Transfer-Encoding: BASE64
Content-Description: Picture B

[encoded jpeg image]


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 unsubscribe, mailto:majordomo at the following message;
unsubscribe 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