Re: SAX: finalising org.sax.xml.Parser

David Megginson (ak117@freenet.carleton.ca)
Tue, 24 Feb 1998 08:46:55 -0500


Don Park writes:

> If I remember correctly, what David is trying to do is provide us with means
> to parse XML data from a byte stream as well as character stream. Since
> Reader will actually hide the byte-based aspect of the data stream, it in
> inappropriate for our purpose.
>
> XML character stream is also very useful when XML data is generated and
> processed within a framework. In such a system, converting character
> streams to byte stream and then converting it back to character stream is
> unnecessary.

This is true, but I think that James's point is well taken. The
character _buffer_ doesn't really buy us anything. I am reluctant to
use a character reader for two reasons:

1) It is a concept that doesn't translate well to languages other than
Java (or even to Java 1.0.2 for that matter).

2) It imposes another architectural requirement on SAX-conformant
parsers (the ability to receive characters directly, bypassing the
normal input mechanisms), and I'm trying to keep interference to a
minimum.

It is slightly inefficient to go from characters to a byte stream to
characters, but it's not that bad (especially if we use ISO-8859-1 or
UCS-2 for the encoding), and it keeps SAX simple and general. Given
the discussion so far, then, we are ending up with something like
this:

package org.xml.sax;
import java.io.InputStream;

public interface Parser {

public abstract void setEntityHandler (EntityHandler handler);
public abstract void setDocumentHandler (DocumentHandler handler);
public abstract void setErrorHandler (ErrorHandler handler);

public abstract void parse (String publicId, String systemId)
throws java.lang.Exception;
public abstract void parse (String publicId, String systemId,
InputStream inputStream)
throws java.lang.Exception;

}

If you need more, you can always extend the interface:

package com.acme.xml;
import java.io.Reader;

public interface SuperParser extends org.xml.sax.Parser {

public abstract void parse (String publicId, String systemId,
Reader reader)
throws java.lang.Exception;

}

In an ideal world, we'd also have some kind of ability to ask to
parser to turn validation on or off, but I'm not certain that that's
practical: any thoughts?

All the best,

David

-- 
David Megginson                 ak117@freenet.carleton.ca
Microstar Software Ltd.         dmeggins@microstar.com
      http://home.sprynet.com/sprynet/dmeggins/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ To (un)subscribe, mailto:majordomo@ic.ac.uk the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)