[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: finalising org.sax.xml.Parser

  • From: David Megginson <ak117@f...>
  • To: "'xml-dev Mailing List'" <xml-dev@i...>
  • Date: Tue, 24 Feb 1998 08:58:41 -0500

perl xml parser abort
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@f...
Microstar Software Ltd.         dmeggins@m...
      http://home.sprynet.com/sprynet/dmeggins/

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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.