Thanks. Here is my findings:
Using the toolbox.xml to define the tool works, but using the
$toolLoader tool does not:
<tool>
<key>xmlTool</key>
<class>org.apache.velocity.anakia.Escape</class>
</tool>
Here is the code:
#set($beginTag = "<font color='blue'>")
#set($endTag = "</font>")
$beginTag
See blue? ## This produces color blue
$endTag
<hr>
$xmlTool.getText($beginTag)
See blue with escape? ## This does not produce blue, so far so good!
$xmlTool.getText($endTag)
<hr>
$toolLoader("xmltool","org.apache.velocity.anakia.Escape") ## This seems
to work
$xmltool.getText($beginTag) ## This does not work
See blue with escape?
$xmltool.getText($endTag) ## This does not work
## The above code outputs
org.apache.velocity.tools.tools.ToolLoader@6d2702("xmltool","org.apache.
velocity.anakia.Escape") $xmltool.getText($beginTag) See blue with
escape? $xmltool.getText($endTag)
## In the log file
2002-07-15 10:36:05 - /VelocityStrutsTest: Velocity [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = /t.vm [line 33,column 1] : $xmltool.getText($beginTag) is not
a valid reference.
2002-07-15 10:36:05 - /VelocityStrutsTest: Velocity [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = /t.vm [line 35,column 1] : $xmltool.getText($endTag) is not a
valid reference.
-----Original Message-----
From: Geir Magnusson Jr. [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 15, 2002 10:00 AM
To: Velocity Developer's List
Subject: Re: HTML escape sequence filtering (is there a tool for that?)
On 7/15/02 9:43 AM, "Ed Yu" <[EMAIL PROTECTED]> wrote:
> I'm looking into JSP migration to Velocity. There is one feature that
> the <bean:write ... filter="true"> tag offer, the ability to filer
> special html characters (<, >, &, etc...). Currently is there a "tool"
> to perform such filtering?
>
Being fundamentally lazy, I just tend to do this :
vc.put("xmltool", new org.apache.velocity.anakia.Escape());
:)
--
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
[EMAIL PROTECTED]
+1-203-247-1713
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>