Re: Generator with XMLFilterImpl
Javier Puerto <[email protected]>
| Newsgroups | gmane.text.xml.cocoon.user |
|---|---|
| Message-ID | <CAACZMNeiozmPpE-Faz432hewU_o-anPAByKRsXXEJ+SdAuWRUw@mail.gmail.com> |
Hi Mansour, 2012/12/6 Mansour Al Akeel <[email protected]> > 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: [email protected] > For additional commands, e-mail: [email protected] > >