Generator with XMLFilterImpl
Mansour Al Akeel <[email protected]>
| Newsgroups | gmane.text.xml.cocoon.user |
|---|---|
| Message-ID | <CAFvvX=afwnm8m2QNq=raHO9c+K88M0uSCd_fKwVRWS4-V4X17Q@mail.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:
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