xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Clark <an...@apache.org>
Subject Re: How to start writing a non-blocking SAX parser
Date Mon, 29 Apr 2002 00:58:07 GMT
Aleksander Slominski wrote:
> and then call:
>         pullParserConfiguration.parse(false)
> this function will deliver one callback and return (true 
> indicates that more input is availabel, false is returned 
> when parsing is finished).

A parser configuration implementing the XMLPullParserConfiguration
interface does not guarantee that one callback will be performed
for each call to parse(false). In fact, the number of callbacks 
can be zero, one, or more. The only thing that it guarantees is
that the parser configuration can break at "reasonable" places
during parsing and return control back to the application.

The reason that a single callback is not guaranteed is due to the 
pipeline nature of the parser configuration. The configuration is 
made up of a series of components and these components may add or
remove events in the pipeline. So even if the scanner produces
only one callback, that callback may turn into multiple callbacks
as it moves through the pipeline. For example: the namespace
binding component receives a startElement event and may produce
any number of startPrefixMapping events in addition to passing
along the startElement event.

However, it's certainly possible that a configuration can be
written that guarantees one and only one callback. It's just
that one hasn't been written, yet. 

I haven't looked into your XPP2 implementation on top of XNI 
so I don't know how you ensure that only one callback gets 
propagated back to the application. Depending on the information 
that you return this is certainly possible for the standard case 
but there may be other parser configuration where the simple 
approach breaks down. 

I have reservations about mixing the API approaches. But that's 
not to say it can't work for all XNI pull-parsing configurations
and that there's no value in such an attempt. It might even be
fun to try. :)

Andy Clark * andyc@apache.org

In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org

View raw message