Return-Path: X-Original-To: apmail-cocoon-users-archive@www.apache.org Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1E57AEC88 for ; Thu, 6 Dec 2012 17:25:58 +0000 (UTC) Received: (qmail 37987 invoked by uid 500); 6 Dec 2012 17:25:57 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 37694 invoked by uid 500); 6 Dec 2012 17:25:57 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 37584 invoked by uid 99); 6 Dec 2012 17:25:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 17:25:55 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jpuerto@gmail.com designates 209.85.215.51 as permitted sender) Received: from [209.85.215.51] (HELO mail-la0-f51.google.com) (209.85.215.51) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Dec 2012 17:25:47 +0000 Received: by mail-la0-f51.google.com with SMTP id e4so4941167lag.24 for ; Thu, 06 Dec 2012 09:25:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Ys3iT6sUNhxHDuzPTql4cGvIFYQUAaQ50fX+18a6O00=; b=LAgnaVBUwYJJRj0K0ANcSyuxStAAIRsLIm351sDMA20o5BypJgAAWfslP/IB3LMWPs 7q+Gc51Bq+8edYypNtIYS8sj8RLsF5QfADZB+JHrEyFZOJ7pICKftl5wgNEdGj0MH2Ij xgL3xl+v7v+0xWjsjK784+ZgwZY2BibbwaqCUe/Vato/UTrVtezuO9squ8yW6DsF0vT0 QWrXg5Ti8SogjPFFRNuXhdlmlnMuI+/vnpz5ITFy/TK3HxTUOwFf0OBlxUqY2gZhS0em pVqEB7CA0XJFucU5YGmzzLkJXNqeSvVHWcEYsa4fHt3leajqM4Ra9Ltd4tHOT/JKd276 x+Ow== MIME-Version: 1.0 Received: by 10.112.40.3 with SMTP id t3mr1319856lbk.48.1354814726966; Thu, 06 Dec 2012 09:25:26 -0800 (PST) Received: by 10.112.46.40 with HTTP; Thu, 6 Dec 2012 09:25:26 -0800 (PST) In-Reply-To: References: Date: Thu, 6 Dec 2012 18:25:26 +0100 Message-ID: Subject: Re: Generator with XMLFilterImpl From: Javier Puerto To: users@cocoon.apache.org Content-Type: multipart/alternative; boundary=e0cb4efe2ea6898d8c04d0326275 X-Virus-Checked: Checked by ClamAV on apache.org --e0cb4efe2ea6898d8c04d0326275 Content-Type: text/plain; charset=ISO-8859-1 Hi Mansour, 2012/12/6 Mansour Al Akeel > 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). Then you can use from other pipelines in the same sitemap like this: .... >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: > 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 > > --e0cb4efe2ea6898d8c04d0326275 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 Tran= sformer is the Cocoon way and simplest (no need of java code).

<m= ap:pipeline match=3D"myCustomFileGenerator/**">
=A0 <map= :generator src=3D"{1}"/>
=A0 <map:transform src=3D"yourXSLT"/>
=A0 <mao:serial= ize/>
</map:pipeline>

Then you can use from other pipeli= nes in the same sitemap like this:

<map:pipeline match=3D"my= /service">
=A0 <map:generate src=3D"cocoon:/myCustomFileGenerator/your/file/to= /consume"/>
=A0 ....

From another block you can consume a= lso with the sevlet: protocol, just add the name of the block with the serv= ice you want to consume:
<map:pipeline match=3D"my/service">
=A0 <map:generate= src=3D"servlet:myBlock:/myCustomFileGenerator/your/file/to/consume&qu= ot;/>



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 {

=A0 =A0 =A0 =A0 @Override
=A0 =A0 =A0 =A0 public void setup(SourceResolver resolver, Map objectModel,= String
src, Parameters parameters) throws ProcessingException, SAXException,
IOException {

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 super.setup(resolver, objectModel, src, par= ameters);

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 LinkValidator validator =3D new LinkValidat= or(this.contentHandler);

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 this.setContentHandler(validator);

=A0 =A0 =A0 =A0 }

=A0 =A0 =A0 =A0 @Override
=A0 =A0 =A0 =A0 public void generate() throws IOException, SAXException, Pr= ocessingException {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 super.generate();
=A0 =A0 =A0 =A0 }

}


Thank you

If you have implemented the XMLFilter al= ready, you can easily transform into a Cocoon transformer, the interface is= very similar.

Salu2.
=A0

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


--e0cb4efe2ea6898d8c04d0326275--