cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robby Pelssers <>
Subject RE: [C3] new pipeline component: variabelExpander
Date Thu, 15 Dec 2011 16:56:13 GMT
Would it be justified to say that it acts as some kind of transformer (although non-xslt based)
in this case which replaces all variable references with the value from the Map or Properties
provided?  And I suppose it works on any text, not just XML?!

Bring it on ;-)


-----Original Message-----
From: [] On Behalf Of Simone Tripodi
Sent: Thursday, December 15, 2011 5:47 PM
Subject: Re: [C3] new pipeline component: variabelExpander

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,

On Thu, Dec 15, 2011 at 5:32 PM, Robby Pelssers <> wrote:
> Hi Simone,
> This sounds useful. But it's not really clear to me as to how this differs from the Stringtemplate
generator which is also part of C3.
> Robby
> -----Original Message-----
> From: [] On Behalf Of Simone
> Sent: Thursday, December 15, 2011 5:25 PM
> To:
> 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
> <project>
>  <target>
>    <delete dir="${build.home}" />
>    <delete dir="${dist.home}" />
>    <echo>A property '${}' inside the text</echo>
>  </target>
> </project>
> users can define their variables (in form of Properties/Map<String,String>):
>        Properties variables = new Properties();
>        variables.setProperty( "build.base", "/Users/cocoon" );
>        variables.setProperty( "build.home", "${build.base}/workspace" );
>        variables.setProperty( "dist.home", "${build.base}/downloads" );
>        variables.setProperty( "", "Cocoon3 rocks!" );
> then creating and run their pipeline adding the VariableExpander:
>        newNonCachingPipeline().setURLGenerator(
> getClass().getResource( "/variables-expander.xml" ) )
>                               .addVariableExpander( variables )
>                               .addSerializer()
>                               .withEmptyConfiguration()
>                               .setup( System.out )
>                               .execute();
> the XML document will be processed by the next component in the
> pipeline will look like:
> <project>
>  <target>
>    <delete dir="Users/cocoon/workspace" />
>    <delete dir="Users/cocoon/download" />
>    <echo>A property 'Cocoon3 rocks!' inside the text</echo>
>  </target>
> </project>
> WDYT? I hope it will be useful for you as well it is for me :P
> Have a nice day, all the best!
> -Simo
View raw message