Hi Simone,

Why this special API call to add it to the pipeline?

I think is should be a regular transformer you can add any number of time 
wherever you need it:

        VariableExpander expander = new VariableExpander();
        expander.addProperty( "build.base", "/Users/cocoon" );
        expander.addProperty( "build.home", "${build.base}/workspace" );
        expander.addProperty( "dist.home", "${build.base}/downloads" );
        expander.addProperty( "text.property", "Cocoon3 rocks!" );

then creating and run their pipeline adding the VariableExpander:

        newNonCachingPipeline().setURLGenerator(
getClass().getResource( "/variables-expander.xml" ) )
                               .addTransformer( expander )
                               .addSerializer()
                               .withEmptyConfiguration()
                               .setup( System.out )
                               .execute();

That makes it also easier to add configuration to the expander, for example:

* use other marker than ${}, in case you may want generate generate a file 
using that syntax for its own purposes 
* what to do if there if the property name is undefined: replace it by nothing 
/ leave as is / throw exception

Also by not just using a stupid property map, it is much easier to avoid 
infinite recursions such as 
setProperty("build.home","${build.home}/workspace"). 

Cheers, Alfred.

-----Original Message-----
From: simone.trip...@gmail.com [mailto:simone.trip...@gmail.com] On Behalf Of 
Simone Tripodi
Sent: Donnerstag, 15. Dezember 2011 18:02
To: dev@cocoon.apache.org
Subject: Re: [C3] new pipeline component: variabelExpander

Hi Robby :)

On Thu, Dec 15, 2011 at 5:56 PM, Robby Pelssers <robby.pelss...@nxp.com> wrote:
> 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?

exactly, it just replaces plain text inside attributes/body elements :P

> And I suppose it works on any text, not just XML?!
>

Not ATM, it works as XmlTransformer :(

> Bring it on ;-)
>

I'll do, thanks! :)
best;
-Simo

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/

The content of this e-mail is intended only for the confidential use of the 
person addressed. 
If you are not the intended recipient, please notify the sender and delete this 
e-mail immediately.
Thank you.

Reply via email to