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

Re: pull variant of lighttweight XML API.

  • From: "Christopher K. St. John" <cstjohn@q...>
  • To: xml-dev@l...
  • Date: Fri, 21 Jul 2000 17:55:27 -0500

expat pull

 Sorry if this is a duplicate, my mail editor crashed.

 I was writing some quick & dirty test code a while back, and 
needed something similiar. I checked the obvious XML-ish places,
but didn't find references to existing code, so I ended up writing
my own (I suspect a more careful search might have turned something up,
but I was in a hurry...) The code isn't fit to be posted, but here's
the relevant comment, hope it's of use:

/**
 * ExpatPull wraps James Clark's expat parser and adapts the interface
 * for pull-based parsing. "Pull based" means that instead of sending
 * the parser data and receiving callbacks, you give the parser the
 * handle to an input stream and ask for elements one at a time. This
 * is a very minimal wrap of the expat code. 
 * <p>
 * It works by buffering up the expat events. A call to read()
 * normally just takes an event off the front of the queue. If there
 * are no events on the queue, <code>ExpatPull</code> repeatedly reads
 * a bit of the stream and feeds it to expat. In response, expat might
 * produce nothing (if you haven't fed it an entire element) or one or
 * more element callbacks. <code>ExpatPull</code> receives the
 * callbacks and buffers up an event object for each one. As soon as
 * there is at least one event in the queue, read() stops feeding
 * expat from the stream and returns the event on the front of the
 * queue.
 *
 * @author Christopher K. St. John
 * @version 0.5 
 *
 */

 
 Although I'm fairly certain it would lack XML nature, I was thinking
it might be fun to hook up such a pull-based interface as the lexer for
a parser generator like ANTLR[1], using wrapped up SAX events as tokens.
(Somebody must have done it, anybody know of such a beast?)


-cks


[1] <URL:http://www.antlr.org>

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.