|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: pull variant of lighttweight XML API.
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! 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
|
|||||||||

Cart








