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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: SAX2: pull interface

[ Lists Home | Date Index | Thread Index ]
  • From: Vilya Harvey <vilya@nag.co.uk>
  • To: David Megginson <david@megginson.com>
  • Date: Tue, 18 Jan 2000 15:31:27 +0000

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,
<snip>

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?

<snip>
> 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,
Vil.
-- 
Vilya Harvey  <vilya@nag.co.uk>    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@ic.ac.uk
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.






 

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

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