cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivelin Ivanov" <ive...@iname.com>
Subject Re: [RT] CallBack Style XML Handlers
Date Tue, 19 Mar 2002 05:23:33 GMT

I maybe a bit too agressive here, so please let me know if so:

Can the caching logic be shifted up one step above the CallBackHandler?
How about a Cacheable CallBackHandlerInterface

interface CacheableCallBackHandler
  {
  boolean hasChanged( String type, Parameters paramList );
  XMLSource event( String type, Parameters paramList );
  }

hence (from your other example):

XMLSource [main]
{
    handle( ContentHandler ch, CallBackHandler cb )
    {
        ch.startDocument();
        ch.startElement( .... );

        XMLSource included;
        if ( cb.hasChanged("xinclude", paramList) )
          {
          included = cb.event( "xinclude", paramList );
          }
        else
          {
          included = pullOutFromCache();
          }

        Included.handle(ch, cb);

        ch.endElement( .... );
        ch.endDocument();
    }
}


>From your email:
>  It is important to preserve the order of the callback
>events, but not necessarily when they are first called.  For instance,
>we can choose to execute the callbacks when we first resolve the source.
>We must include the results at the location where they are needed.

It would be really cool if an XMLSource (which is otherwise
static/cacheable) can somehow iterate before starting to fire events through
its callback segments and if they all haven't changed then the whole
XMLSource can report that it hasn't changed, thus the next transformation
can be skipped.

Maybe another modification of the code above (although I don't quite
understand yet  the current caching mechanism ):

XMLSource [main]
{

    boolean hasChanged()
      {
      iterate over callback elements and if none has changed then return
true, so that the whole document is pulled from the cache
      otherwise return false
      }

    // if some of the callback handlers HAS changed though, we'll still need
to do this
    handle( ContentHandler ch, CallBackHandler cb )
    {
        ch.startDocument();
        ch.startElement( .... );

        XMLSource included;
        if ( cb.hasChanged("xinclude", paramList) )
          {
          included = cb.event( "xinclude", paramList );
          }
        else
          {
          included = pullOutFromCache();
          }

        Included.handle(ch, cb);

        ch.endElement( .... );
        ch.endDocument();
    }
}


> The first thing we need to do is put the interfaces (after we agree on
> Them) into CVS.  As a starting point, we can automagically convert
> XInclude directives into XMLCallBack events.  That way, we don't need
> a separate transformer, and include operations that would normally be
> expensive can be made quick and painless.
>
> Once we have the XInclude set in place, we can take advantage of a small
> cache size, and look into converting other pieces over to the policy
> as well.
>
> Does this sound good as a starting point?


You bet it does !


Ivelin



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message