commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Schofield <>
Subject Re: [chain] add expression evaluation?
Date Sat, 04 Dec 2004 16:51:52 GMT
I too was unaware of this aspect of Digester (apparently it was added
in the latest release.)  I agree with Joe's take that it appears to be
only helpful during the initial parsing of the rules.

I have dealt with something similar myself.  Basically I had some XML
template that I wrote to convert into PDF's.  We used Apache FOP to do
this but that's not really relevant.  The point was that we would have
things in the template that needed to be determined at runtime (such
as a person's name and contact information.)

The way we solved this was using Jakarta's Velocity.  Basically we had
a utility class with a method like this:

    public static String getText(String template, Map context) throws Exception
        StringWriter writer = new StringWriter();

        // setup velocity
        VelocityContext velocityContext = new VelocityContext(context);

        writer = new StringWriter();
        Velocity.evaluate(velocityContext, writer, "", template);

        return writer.toString();

The velocity engine did everything for you.  If your text did not have
velocity markup in it, no harm done, it just ignores it.  Maybe we
could use something like this.  Also, VelocityContext really just
wraps a HashMap, so it might be possible to take advantage of the
chain's Context object.


> I hadn't seen that -- and it's very cool!
> But a quick look leads me to believe that it would be evaluated only
> once, at XML ingestion time, while in the context I'm thinking of,
> the value of the expression would be dependent on the runtime state
> of the context.  With Chain, I think that would be very powerful.
> Joe

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message