[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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, <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@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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|