SAX: Byte Streams and Character Streams
ak117 at freenet.carleton.ca
Sat Apr 18 03:00:12 BST 1998
James Clark has recently raised the issue of byte streams and
character streams, and I think that we need to give this a thorough
discussion before my self-imposed deadline of next Tuesday.
SAX is based on two general principles, sometimes violated:
1) SAX shall provide the minimum required information in the simplest
2) SAX shall impose as few constraints as possible on the
architecture of XML parser implementations.
One possible violation of both principles is my recent suggestion
(implemented in yesterday's pre-release) that SAX support stream-based
parsing only from character streams and not from byte streams -- the
problem is that James's XP parser works directly from undecoded byte
streams for the sake of speed, and this decision requires XP to
reencode the character stream before parsing it.
There are three possible parsing situations:
a) the application provides the parser with a URL pointing to an XML
b) the application has access to characters (perhaps in a buffer, or
or from a database), and it provides them to the parser in a
character stream; and
c) the application has access to raw bytes (perhaps from a file or a
URL connection), and it decodes them and provides them to the
parser in a character stream.
In the first two situations, the absence of a byte stream creates no
inefficiencies -- in (a), the XML parser can read a raw byte stream
itself, and in (b), either the application or XP will have to encode
the characters into bytes. The only inefficiency is in (c), where the
application will decode the byte stream only to have it re-encoded
into bytes by XP, and this is an inefficiency only if the SAX parser
happens to work directly from raw bytes without decoding them first.
I'd like to hear from XML application writers: which of the above
situations do you find most typical? Is (c) a common situation for
you? Is it common enough that it is worth enlarging SAX and
complicating the EntityResolver interface?
Thanks, and all the best,
David Megginson ak117 at freenet.carleton.ca
Microstar Software Ltd. dmeggins at microstar.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/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev