velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geir Magnusson Jr <>
Subject Re: XML and velocity
Date Sat, 04 Dec 2004 11:28:28 GMT

On Dec 2, 2004, at 12:47 PM, Subbiah wrote:

> Thank you all for your input, it clears some parts of the quetsion.
> As you might have quest I have just started using velocity.(a week)
> My generic question on VELOCITY is this.
> 1.  I see velocity very similar to adding sessions in servlets and 
> accessing
> them  in the jsp pages. Is this correct ?

No :)

It's mostly used that way - as a rendered for the web - but it's used 
in lots of other places as well.  (For example, the IDEA IDE uses 
velocity for it's templates for comments and headers and such...  it's 
a hoot to use, because you can use the context variables to have 
different javadoc templates for different projects that you work on...)

> 2. I am using VELOCITY to generate templates for certain messages that 
> will
> be filled at run time. The input is XML and output is any file. We use
> velocity because, the client can change the template anytime his fomat
> changes, but after using velocity [I might be wrong] I feel he still 
> has to
> know the details of the object or java classes to use velocity , for 
> example
> I use DOM parser, then the client has to know what methods are there 
> to make
> a change in the template.This is like changing the source code of the
> generator one thing he need do is rebuild.
> Is this the advantage that velocity provides or are that more that my 
> short
> sightedness prevenst me from seeing [I am sure there are]

The key then is to not depend on DOM.  digest the document into a class 
that the customer can understand, or if the customer understands the 
XML structure, use something that helps them with that.  A while ago, I 
had a little bean that digested an XML document, and let you just use 
in velocity as :


I'll see if I can find it.


> Thank you.
> ~Subbiah
>> -----Original Message-----
>> From: Mike Kienenberger []
>> Sent: Thursday, December 02, 2004 10:04 AM
>> To:
>> Cc:
>> Subject: Re: XML and velocity
>> Subbiah Raman <> wrote:
>>> I am trying to use a SAX parser in Velocity context and I
>> need to do
>>> the following
>>> #set($temp = "$root.getRootElement().getChild("email").getText() )
>>> But it throws
>>> org.apache.velocity.exception.ParseErrorException:
>> Encountered "email"
>> In addition to what others have said, you can also use
>> single-quotes inside your double-quotes.
>> #set($temp = "$root.getRootElement().getChild('email').getText()" )
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:
Geir Magnusson Jr                                  +1-203-665-6437

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

View raw message