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

Re: SAX2: pull interface

  • From: Vilya Harvey <vilya@n...>
  • To: David Megginson <david@m...>
  • Date: Tue, 18 Jan 2000 15:31:27 +0000

Re: SAX2: pull interface
David Megginson wrote:
> SAX is very much a push interface, but some people have asked if it
> might be possible to add optional support for pull,

I think this is a very useful idea. It makes it a lot easier to write
recursive descent parsers for XML grammars, rather than having to muck
about with state tables and the like.

It is not clear whether this should to be part of SAX though. As you
mention, the SAX interface has a very definite viewpoint of parsing which
seems almost diametrically opposed in many ways to a "pull" interface.
Perhaps it would be more appropriate to define a completely separate API
for this?

> 1. Is this adequate for the people who want pull?  I really don't want
>    to define a separate object for each event type (especially when we
>    allow arbitrary extension handlers).

In general I prefer to think of a pull API in terms of tokens rather than
events. I would like to have a base interface ("Token") which is extended
by interfaces for elements, processing instructions, etc. and a method in
the parser interface which returns the next token from the input (or null
if the input has been exhausted), whatever it may be. Which I believe is
almost exactly what you said you didn't want. :-)

Another alternative is simply to have the parser store all of the
information about the current token and provide access to it via methods.
The nextToken() method would just need to return a constant indicating the
type of token which was read. This could be implemented more efficiently,
but would obviously be less extensible.

Just thinking out loud really,
Vilya Harvey  <vilya@n...>    Wilkinson House  Mob: +44  961 106 505
Computational Mathematics Group   Jordan Hill Road   Wk: +44 1865 511 245
NAG Limited                    Oxford  UK  OX2 8DR  Fax: +44 1865 311 205

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/ or CD-ROM/ISBN 981-02-3594-1
Please note: New list subscriptions now closed in preparation for transfer to OASIS.


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.
First Name
Last Name
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.