OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: finalising org.sax.xml.Parser

[ Lists Home | Date Index | Thread Index ]
  • From: David Megginson <ak117@freenet.carleton.ca>
  • To: "'xml-dev Mailing List'" <xml-dev@ic.ac.uk>
  • Date: Tue, 24 Feb 1998 08:58:41 -0500

Michael Kay writes:

 > Comments:
 > 1. Is the (ch, start, length) method really necessary, given that one can
 > supply a StringReader or whatever to the parse(InputStream) method?

James has convinced me that it's not -- I'm actually happy to drop it,
since I want to keep the interfaces as simple as possible both to
learn and to implement.

 > 2. If my "main" XML document is in a record in a database, then it is very
 > likely that any other entities referred to will be in the database as well.
 > Therefore, I think the logical approach in this situation is for the
 > application to resolve all URIs encountered: the parser should call the
 > application supplying a URI and the application should return an InputStream
 > to allow the parser to read it. This should presumably be done via the
 > EntityHandler interface.

I have considered this approach, but I can anticipate two problems:

1) It puts the burdon of resolving URIs on the application rather than
   the parser.

2) It is possible that some programming languages or libraries do not
   represent network connections as input streams.

If (2) isn't a problem, we might find a way to work around (1).  I'll
be coming back to the EntityHandler interface in a future posting, and
we can take up the issue again then.

 > And a question: is there a recommended way to abort a parse once the
 > application has got the information it needs (e.g extracting the contents of
 > the TITLE element)? Would an interface like parser.abort() be cleaner than
 > playing around with exceptions? I ask because in handling the results of a
 > free text search, I am parsing all the retrieved documents when I only need
 > a bit of text from the beginning of each, and this is obviously wasteful. I
 > thought perhaps of supplying a stream and generating a premature
 > end-of-file, and then trapping the exception that comes back.

In languages that support exceptions (Java, C++, Perl, and sort-of C),
an exception is probably the cleanest way to handle this.  It also
lets you pass application-specific information back to the top level
within your exception.


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)





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS