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

Re: parser models


push parser pull parser

where the parser manages a construction context and offers the application control over the initial context and a mechanism to generate new contexts, a pull
parser is the same as a push parser.

the wilbur rdf parser was originally written to a sax-like parser interface. by implementing the appropriate behaviour in cl-xml's construction contexts, it was
trivial to use it - ostensibly a pull parser - to drive wilbur's rdf construction logic, that is, to turn it around from being a pull parser to being a push parser.

in the case of a pull parser, calls like currContent.newChild, below, produce instances which are eventually passed back to the application, while in a push
parser they pass control into the application. there is little difference between the two. it would even be possible to implement construction contexts which
did both.

nb. it is better for the interface and logic to distinguish between the construction context and the constructed instance and to permit the application the
opportunity to decide whether they coincide.

Arjun Ray wrote:
> 
> ...
> 
> In search of a more "natural" idiom, I've been experimenting with a pure
> push API which supports stack-based delivery of events.  It's built around
> two mutually dependent interfaces that the consumer will have to implement
> which look like this (many details omitted):
> 
>   interface Element {
>       void      gi( String name ) ; // the element type
>       AttList   attlist( ) ; // an interface to push attribute info
>       Content   content( ) ;
>   }
> 
>   interface Content {
>       Element   newChild( ) ;
>       Content   endChild( Content child ) ;
>       void      text( char[] buf, int len, int off, boolean pcData ) ;
>       void      endContent( ) ;
>   }
> 
> The parser will maintain a stack of deferred Content instances and a
> "current Content instance", tracking the open element hierarchy.  The
> normal operation goes like this
> 
>   1.  Parser has a start-tag:
>        - calls currContent.newChild() to get an Element instance (which
>          is basically a context sensitive factory-like constructor).
>        - ...
> 
>   2.  ...
> 
>   3.  ...

...

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.