velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: How to use EscapeTool
Date Tue, 29 Aug 2006 21:10:17 GMT
That is highly perplexing.  The code as you show it should work
perfectly as long as the EscapeTool is present in the context.  And if
it were not, the key part of the result would look like:

${esc.xml(...)}

Since EscapeTool is basically just a wrapper for Common Lang's
StringEscapeUtils, you might check that you have a working version of
that in the classpath (though to my knowledge, it has never been
broken).

Given what you say, i really have no idea what could be causing the
escaping to fail.  All i can suggest is that you double check that
everything is as you describe and nothing is cached.

On 8/29/06, Duttaroy, Debasish <debasish.duttaroy@fmr.com> wrote:
> Hi
> I am new to Velocity. Here is my requirement.
>
> I want the velocity template to spit out a xml output. Basically, my .vm
> file is a xml template. I am able to achieve this. Now I want the data
> inside this xml document to be escaped.
>
> What is the best way to do this.
>
> My understanding is this should be done with the help of EscapeTool.
> BTW, I use Spring MVC. This is what I do:
>
> My hello.vm
>
> ## Velocity Hello World
> <?xml version="1.0"?>
> <headlines>
>         <lineitem>
>
> <headlinetext>${esc.xml($headline.headlineText)}</headlinetext>
>         </lineitem>
> </headlines>
>
> Required output
>
> <headlines>
>         <lineitem>
>                 <headlinetext>Times &amp; Warner</headlinetext>
>         </lineitem>
> </headlines>
>
>
> Actual Output
>
> <headlines>
>         <lineitem>
>                 <headlinetext>Times & Warner</headlinetext>
>         </lineitem>
> </headlines>
>
>
> I put toolbox.xml inside WEB-INF
>
> <?xml version="1.0"?>
> <tool>
>         <key>esc</key>
>         <scope>application</scope>
>         <class>org.apache.velocity.tools.generic.EscapeTool</class>
> </tool>
>
>
> What else do I need to do. If anyone can provide a step by step method
> to best way of doing escaping that will be great. I can achieve what I
> want by some crude means, but I want the best practice not the hack.
>
> Thanks in advance
> Debasish
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message