Hi Christoph, Thanks a lot for replying back. As far as the suggestions you gave, i can't use failsafe escaping apporoach as i am not hardcoding the values in the template. As i said earlier, we are having an xml file where in we define element name and its value as <element name="myvar"> <value>User can enter what ever text they want here</value> </element> And we are reading the xml and dynamically creating the variables and associating them with the values to the context using renderTool as below in template $render.recurse($ctx, '\#set($$nameObj = "$theValue")' ) where $nameObj contains the variable name and the $theValue contains the text between <value> and </value>. And regarding using single quote approach, as the recurse has to evaluate my #set, i think the syntax i have given is correct. Tried changing the syntax also by giving single qoutes with escaping for $theValue, but getting some parser errors. So, if i can get a list of characters which will create problems in #set directive like ##, newline etc... i can ask the users not to use them or try to escape them in the xml itself.... Any suggetions will be of great help.
-- With Regards, Ravikanth.L On 9/19/05, Christoph Reck <[EMAIL PROTECTED]> wrote: > > Hi, > > Ravikanth L wrote: > > Hi All, > > I would like to know the valid characters that we can use for a value in > > VTL. I tried the following > > #set($var = "My string with special chars##") > > Velocity defines a line-comment starting with the characters ## > Also note that Velocity offers a feature called "string interpolation", > where within a directive (#if and #set) the references inside double > quotes are evaluated and inserted. > > You have detected a parser bug, where it chokes on the fact that the > EOL-comment is not compatible with the interpolation. > > Please consider using single quotes or using a failsafe escaping: > #set( $var = 'My string with special chars##' ) > #set( $H = '#' ) > #set( $var = "My string with special chars$H$H" ) > > I am aware of some issues that are related to the problem (maybe you can > vote on them): > http://issues.apache.org/jira/browse/VELOCITY-126 "String containing '##' > is treated as unterminated String" > http://issues.apache.org/jira/browse/VELOCITY-355 "lost '#'s inside > #literal()/#end" > http://issues.apache.org/jira/browse/VELOCITY-272 "EOF exception when last > line is commented out and has no new line at end" > http://issues.apache.org/jira/browse/VELOCITY-253 "Enhance whitespace > gobbling" - involves parser syntax simplification > > Hope this helped, > Christoph > > > It throws ParseErrorrException as: > > org.apache.velocity.exception.ParseErrorException: Lexical error: > > org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line > 1, > > column 19. Encountered: <EOF> after : "". > > It didn't complain if i use single #. So, i would like to know what all > > character combinations will result in ParserErrorException without any > > escaping done, bcoz we are reading variable names and their values from > an > > XML file and constructing variables dynamically using RenderTool. > > Tried to find in User docs but no luck. > > Can anyone pls let me know the list or point me to the link where i can > get > > the details. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
