cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gelo1234 <gelo1...@gmail.com>
Subject Re: Generator with XMLFilterImpl
Date Thu, 06 Dec 2012 19:13:59 GMT
If you need to do this in generator why not writing your own Generator ?
that extends AbstractSAXGenerator ?
You can find example in:
cocoon-sample/src/main/java/org/apache/cocoon/sample/generation/

Greetings,
Greg

2012/12/6 Mansour Al Akeel <mansour.alakeel@gmail.com>

> Javier, thank you for replying.
> For many additional reasons, I need to do this in a generator. It's
> not my call on this. So I need to connect the XMLFilterImpl to the
> Generator.
> I know it can be done, but looking for the simplest and cleanest way.
>
>
> On Thu, Dec 6, 2012 at 12:25 PM, Javier Puerto <jpuerto@gmail.com> wrote:
> > Hi Mansour,
> >
> > 2012/12/6 Mansour Al Akeel <mansour.alakeel@gmail.com>
> >>
> >> Hello all,
> >> I am using C2.2 for this project, and I need to add some functionality
> >> to the current file generator (ie, logging and warning for broken
> >> links). I know this can be done in a transformer,
> >> but since it's required in many places, I want it in the Generator.
> >>
> >>
> >> Since the generator, generates SAX events, the simplest way is to
> >> insert an XMLFilterImpl that does the logging, between the generator
> >> and the consumer. For example:
> >
> >
> > I think that use a Transformer is the Cocoon way and simplest (no need of
> > java code).
> >
> > <map:pipeline match="myCustomFileGenerator/**">
> >   <map:generator src="{1}"/>
> >   <map:transform src="yourXSLT"/>
> >   <mao:serialize/>
> > </map:pipeline>
> >
> > Then you can use from other pipelines in the same sitemap like this:
> >
> > <map:pipeline match="my/service">
> >   <map:generate
> src="cocoon:/myCustomFileGenerator/your/file/to/consume"/>
> >   ....
> >
> > From another block you can consume also with the sevlet: protocol, just
> add
> > the name of the block with the service you want to consume:
> > <map:pipeline match="my/service">
> >   <map:generate
> > src="servlet:myBlock:/myCustomFileGenerator/your/file/to/consume"/>
> >
> >
> >>
> >> Currently:
> >>
> >> FileGenerator --> events ---> XMLConsumer
> >>
> >> I need it to be:
> >>
> >> FileGenerator --> events --> XMLFilterImpl ---> XMLConsumer
> >> OR
> >> FileGenerator --> events ---> XMLConsumer --> XMLFilterImpl
> >>
> >> The issue is I couldn't find any example on connecting and setting up
> >> a filter between the generator and the consumer.
> >> Additionally, setting the contentHandler doesn't seem to have any
> >> effect. Currently this is what I have and the events are not passing
> >> through LinkValidator Filter.
> >>
> >>
> >> public class MyGenerator extends FileGenerator {
> >>
> >>         @Override
> >>         public void setup(SourceResolver resolver, Map objectModel,
> String
> >> src, Parameters parameters) throws ProcessingException, SAXException,
> >> IOException {
> >>
> >>                 super.setup(resolver, objectModel, src, parameters);
> >>
> >>                 LinkValidator validator = new
> >> LinkValidator(this.contentHandler);
> >>
> >>                 this.setContentHandler(validator);
> >>
> >>         }
> >>
> >>         @Override
> >>         public void generate() throws IOException, SAXException,
> >> ProcessingException {
> >>                 super.generate();
> >>         }
> >>
> >> }
> >>
> >>
> >> Thank you
> >
> >
> > If you have implemented the XMLFilter already, you can easily transform
> into
> > a Cocoon transformer, the interface is very similar.
> >
> > Salu2.
> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> >> For additional commands, e-mail: users-help@cocoon.apache.org
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Mime
View raw message