SAX: New Idea for Entity Resolution

David Megginson ak117 at freenet.carleton.ca
Sun Apr 19 13:40:59 BST 1998


James Clark writes:

 [on org.xml.sax.CharacterStream and org.xml.sax.ByteStream]

 > Why are the single character read calls there?  They unnecessarily
 > complicate the interface.

For others in the discussion, here's what I have right now:

  public interface CharacterStream {
    int read () throws SAXException;
    int read (char ch[], int start, int length) throws SAXException;
  }

  public interface ByteStream {
    int read () throws SAXException;
    int read (byte b[], int start, int length) throws SAXException;
  }

I included the single character/byte reads because I did not want to
assume that all SAX parsers do their own buffering (of course, the
buffering could be handled in the SAX driver layer if necessary).  

It also seems strange to me to have a streaming interface that does
not allow single character/byte reads, though I know that these would
be horribly inefficient in a distributed environment where the Parser
and the CharacterStream or ByteStream are on different systems.

What do the other parser writers think?  Does anyone want or need
single-character or single-byte reads?  I'm very happy to prune SAX
wherever I can, before we get to the final release.

 [on the new InputSource class]

 > > Now, we can get away with only one parse() method in
 > > org.xml.sax.Parser:
 > > 
 > >   public abstract void parse (InputSource source)
 > >     throws Exception;
 > 
 > I don't think this is a good idea: it makes SAX harder to use in the
 > simple case of reading from a URL.

In that case, then, it would probably be best to have two:

  public abstract void parse (String systemId)
    throws Exception;

  public abstract void parse (InputSource source)
    throws Exception;

The first would be the exact equivalent of

  public void parse (String systemId)
    throws Exception
  {
    parse(new InputSource(systemId));
  }

Does this seem reasonable?


Thanks, and all the best,


David

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

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;
(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