cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier del Gesu <>
Subject Re: EffectTransformer/WoodyTemplateTransformer
Date Tue, 14 Oct 2003 21:02:57 GMT
* Timothy Larson <> [2003-10-14 19:00]:
> (Note to Javier: I am fowarding my reply to the list, since I saw your
> public reply just moments after I had already sent this reply privately)
> --- Javier del Gesu <> wrote:
> > This is reassuring. I wrote something similiar to create a SAX
> > filter, where processing of diferent nodes is handled by different
> > objects.

> This is where the poor man's continuations come in handy.  I have some
> techniques that allow loops and other code structures to be continued.
> These features do not get used in the WoodyTemplateTransformer, but I
> plan to use them in processing other structured data in other projects.
> I like your put/get interface for communicating data between handlers.
> That concept may get used when the Effect transformer gets exteded to
> handle multiple inputs and outputs and a few other things...

Futher consideration (these are examples, not actual code):

class ExampleFilter extends AbstractContentFilter {
    private String command;
    private CollectionFilter collectionFilter;

    public ExampleFilter () {
        collectionFilter = new CollectionFilter();

    public void start (FilterContext filterContext,
        SAXStartElementEvent event) throws SAXException {

    public void startElement (FilterContext filterContext,
        SAXStartElementEvent event) throws SAXException {

        String localName = filterContext.getLocalName();

        if (localName.equals("document")) {

            // Reuse a common component.

            // Build a DOM document and put it user the key "doc"
            // in the filter context.

            filterContext.startContentFilter(new DOMFilter("doc"));

        } else if (localName.equals("command")) {
            // Create an anonymous inner class to intercept a value.

            ContentFilter anonymous = new AbstractContentFilter () {
                public void characters (FilterContext filterContext,
                    SAXCharacterEvent event) throws SAXException {
                    ExampleFilter.this.command =

        } else if (localName.equals("item")) {

            // Use the same filter for a certian set of element
            // names, preserves state.

            // Is this what you mean by continuations?



    public void end (FilterContext filterContext, SAXEventEvent event)
        throws SAXException {

        if (command != null)

        Document document = (Document) filterContext.get("doc");
        if (document != null)

        Object items[] = collectionFilter.toArray();

Did I cover all the bases?

Javier del Gesu -

View raw message