You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Andy Clark <an...@apache.org> on 2000/08/01 01:51:32 UTC

Re: Pull-model parser

Costin Manolache wrote:
> I think it would be much cleaner and simpler to not use the callbacks.
> 
> Something like:
> 
> void parseNext( XMLHolder h )
> 
> Where XMLHolder will have a getType() = ( TAG, ATTRIBUTE, CDATA, etc).
> 
> XMLHolder {
>   int getType();
>   XMLString getTag();
>   XMLString getAttributeName();
>   XMLString getAttributeValue();
>   CharChunk getCdata(); ( or getChars(), getOffset(), getLength()  )
> }

Having a switch statement based on the type and performing some
action is no different than registering a handler that receives
callbacks at each "pull". And I think it's easier compared to
the XMLHolder because the handling mechanism is the same whether 
you pull the events or if the parser notifies you of all of the
events.

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org

Re: Pull-model parser

Posted by Costin Manolache <co...@eng.sun.com>.
> Having a switch statement based on the type and performing some
> action is no different than registering a handler that receives
> callbacks at each "pull". And I think it's easier compared to
> the XMLHolder because the handling mechanism is the same whether
> you pull the events or if the parser notifies you of all of the
> events.

Both methods are ok - they allow getting the next "piece" from
the XML file and process it.

I don't agree it's simpler to write callbacks than it is to use a
switch.  Also, I don't think the 2 methods are equivalent -
you can generate callbacks from the switch, but if you
do callbacks you can't provide the same functionality
as in switch ( each callback is in a different context, stack,
etc, local variables don't work).

In some cases it may be much simpler ( and maybe faster ) to
use the switch() method. I don't know - it's worth
exploring both alternatives.

Costin