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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: pull variant of lighttweight XML API.

[ Lists Home | Date Index | Thread Index ]
  • From: "Christopher K. St. John" <cstjohn@quik.com>
  • To: xml-dev@lists.xml.org
  • Date: Fri, 21 Jul 2000 17:55:27 -0500


 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>




 

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

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