Return-Path: X-Original-To: apmail-cocoon-dev-archive@www.apache.org Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0B5837165 for ; Thu, 15 Dec 2011 16:47:32 +0000 (UTC) Received: (qmail 52923 invoked by uid 500); 15 Dec 2011 16:47:31 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 52876 invoked by uid 500); 15 Dec 2011 16:47:31 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 52869 invoked by uid 99); 15 Dec 2011 16:47:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Dec 2011 16:47:31 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of simone.tripodi@gmail.com designates 209.85.212.51 as permitted sender) Received: from [209.85.212.51] (HELO mail-vw0-f51.google.com) (209.85.212.51) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Dec 2011 16:47:23 +0000 Received: by vbbfp1 with SMTP id fp1so2275639vbb.24 for ; Thu, 15 Dec 2011 08:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; bh=SAUJgl02GmIllOW8tuKEbzr6eXlK0JnpgFWl/4uKvBo=; b=JjHZDJQp7gaPqZLgiXG7NSlFG34/obQp1DuyIsGGOVh9sZUkzi7xliRZPgwT+WoaYq /heXJl55jV/1cgWdAJSPqctpoTG8JkXf65cLCmgnBRIkK61yBSZYifZvqUVJ/62nf/N7 K95kPJNuYxdFcM2wsvb7DOI9RlVct8K1OGJ+s= MIME-Version: 1.0 Received: by 10.52.94.75 with SMTP id da11mr3584808vdb.111.1323967621895; Thu, 15 Dec 2011 08:47:01 -0800 (PST) Sender: simone.tripodi@gmail.com Received: by 10.52.75.161 with HTTP; Thu, 15 Dec 2011 08:47:01 -0800 (PST) In-Reply-To: <78B923726E7D59429936580CF127E943A1F35896CD@eu1rdcrdc1wx032.exi.nxp.com> References: <78B923726E7D59429936580CF127E943A1F35896CD@eu1rdcrdc1wx032.exi.nxp.com> Date: Thu, 15 Dec 2011 17:47:01 +0100 X-Google-Sender-Auth: NJM7ADSZTYA4Sr4Z3QpOLYxMkxQ Message-ID: Subject: Re: [C3] new pipeline component: variabelExpander From: Simone Tripodi To: dev@cocoon.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi Robby! The Stringtemplate generator is much more sophisticated (you have iterators, access to objects methods, ...) compared to this simple component, that simply provides variable expansion. The other difference is: Stringtemplate is a generator, the VariableExpander is a component you can put in the middle of the pipeline whenever you need - in my case, I needed to plug it at the 3rd stage of the pipeline. For what it worths, Stringtemplate generator brings a 3rd party dependency, VariableExpander comes dependencies-free inside the cocoon-sax package. Hope this clarifies, don't hesitate to ask if you need to know more! All the best, -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ On Thu, Dec 15, 2011 at 5:32 PM, Robby Pelssers wr= ote: > Hi Simone, > > This sounds useful. But it's not really clear to me as to how this differ= s from the Stringtemplate generator which is also part of C3. > > Robby > > -----Original Message----- > From: simone.tripodi@gmail.com [mailto:simone.tripodi@gmail.com] On Behal= f Of Simone Tripodi > Sent: Thursday, December 15, 2011 5:25 PM > To: dev@cocoon.apache.org > Subject: [C3] new pipeline component: variabelExpander > > Hi all guys, > I just committed r1214835 a new component I need for work, so I > thought it would have been a good idea contributing back to OSS since > C3 is the foundation of the XML processor I am writing. > > Basically, I needed to put variables inside our XML document that can > be replaced depending by the context the pipeline works, so the idea > came from Ant/Maven and some code I already did in Commons-Digester, > using the ${} marker for variables have to be expanded. > > Using that new component is very simple: given the XML > > > =C2=A0 > =C2=A0 =C2=A0 > =C2=A0 =C2=A0 > =C2=A0 =C2=A0A property '${text.property}' inside the text > =C2=A0 > > > users can define their variables (in form of Properties/Map): > > =C2=A0 =C2=A0 =C2=A0 =C2=A0Properties variables =3D new Properties(); > =C2=A0 =C2=A0 =C2=A0 =C2=A0variables.setProperty( "build.base", "/Users/c= ocoon" ); > =C2=A0 =C2=A0 =C2=A0 =C2=A0variables.setProperty( "build.home", "${build.= base}/workspace" ); > =C2=A0 =C2=A0 =C2=A0 =C2=A0variables.setProperty( "dist.home", "${build.b= ase}/downloads" ); > =C2=A0 =C2=A0 =C2=A0 =C2=A0variables.setProperty( "text.property", "Cocoo= n3 rocks!" ); > > then creating and run their pipeline adding the VariableExpander: > > =C2=A0 =C2=A0 =C2=A0 =C2=A0newNonCachingPipeline().setURLGenerator( > getClass().getResource( "/variables-expander.xml" ) ) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .addVariableExpander( variables ) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .addSerializer() > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .withEmptyConfiguration() > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .setup( System.out ) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .execute(); > > the XML document will be processed by the next component in the > pipeline will look like: > > > =C2=A0 > =C2=A0 =C2=A0 > =C2=A0 =C2=A0 > =C2=A0 =C2=A0A property 'Cocoon3 rocks!' inside the text > =C2=A0 > > > WDYT? I hope it will be useful for you as well it is for me :P > Have a nice day, all the best! > -Simo > > http://people.apache.org/~simonetripodi/ > http://simonetripodi.livejournal.com/ > http://twitter.com/simonetripodi > http://www.99soft.org/