You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Christoph Reck <Ch...@dlr.de> on 2000/12/06 15:09:07 UTC

Re: Pittfalls in migration from WM to VL

Many of the bugs are still in there. It is keeping me from 
moving from WM to V. I'm reaching the point where I cannot
continue, since I need VMs.

I detected two more buglet...

* Escaping some reference within a parsed template is not
  respected. Add the follwing line to test/templates/parse.vm
  and parse1.vm and see the difference...
    \$list is a $list.Class.Name with length $list.size()

* More problems with method invocations (also see turbine list
  message "Scheduler") following example does not work:
    #set $foo = $list.set(0, "ArrayList element x")
    Changed first element from "$foo" to "$list.get(0)"

>[snip]
> * A #set with a following comment causes a NPE, e.g:
>   #set $color = "0x8080FF" ## light blue

still there...

>[from another thread to this subject]
> > Currently, the #set is to be kept alone on its own line.
> > 
> > We are going to normalize the set directive :
> >    
> >    #set( expression )
> > 
> > to look like other directives, and then deprecate the current 
> > #set over time.
Such a change would require voting. for me it's -1, even though
my vote doesn't count (yet). I would like to be able to have
all directives standalone each in its own line to keep them 
visually separate from the content (whithout them polluting 
the output - even of the #D's are indented). I don't see a reason 
for embedded #set directives. Well I would agree that if a
#set() is used to create context objects, then a #macro should 
also...

> * A file ending in a ## without an EOL emits a TokenMgrError.

still there...

> * A #set without an "=" emits a NPE instead of an apropiate
>   error message.

still there...

> * The negation in #if ( !$foo ) 

fixed..

> * A method invocation (which is not a getXXX) without parameters
>   requires an empty braket set, else it throws a ClassCastException,
>   e.g. add following line to the example.vm: length=$list.size

still there...

> * A null assignment (e.g. returned from a method call) leaves the
>   variable unchanged, e.g:

still there...
Here a better example for the test templates:

  #set $foo = ""
  The contents of foo after "\#set \$foo = \$list.get(0)" is:
  #set $foo = $list.get(0)
  $foo

  Getting element 5 should return null
  So what's in foo after "\#set \$foo = \$list.get(5)":
  #set $foo = $list.get(5)
  #if ( $foo )
    \$foo should have contained NULL (has "$foo")!
  #else
    $foo is now correctly NULL.
  #end

> 
> * Hastables are known to a foreach, but not to set. The WM syntax
>   #set $provider.Hashtable.NEW_KEY = "a string"
>   does not do anyting. How does one set a value into a Hastable without
>   emitting the previous content? does one need to do:
>   #set $dummy = $provider.Hashtable.put("NEW_KEY", "a string")

still there...

> 
> * Whitespaces around standalone #if, #else, #end are preserved,
>   it should be possible to handle them like a #set
>[snip]
> * Pluggable directives should contain a flag on the interface that
>   states if whitespaces should be removed when these are standalone.
>   A #parse should not touch whitespaches, whereas a #include should

still not there...

> > So directives don't emit the EOL, but they will produce the whitespace
> > on the left.

Why is the following emmitting two EOLs between the output lines?
---
Testing it:
#if ($condition)
    The condition is true!
#else
    The condition is false or is not set!!
#end
---
outputs:
---
Testing it:

    The condition is false or is not set!!
--- 

I would like to be able to have directives standalone each 
in its own line to keep them visually separate from the content 
(whithout them polluting the output - even of these are indented).

> 
> * The current snapshot contains new xalan/xerces which is not
>   compatible with the included JTest.

still there... 'build-velocity.sh test' does not work.

> 
> * The example/test.sh in the current snapshot is referencing
>   velocity-0.4.jar instead of the generated 0.5

fixed.

> 
> * The build-velocity.sh just does a prepare as the default target,
>   I would expect it to do at least a compile and jar (as the
>   install.html states).

fixed.

>[from other mail in the same thread:
> 1. How can I define reference to a string containing a quote: e.g.:
>      #set $width=" width=\"$value.getAttributeValue("width")\""
>    is this escaping within a string possible?
(note that I made a similar question with allowing mixing single
 and double quotes in another thread).

Related to this: are multiline strings possible somehow? e.g.:
#set $xmlString = "<xml>
  <item value='123'>
</xml>"

> 
> Please let me know if I should dig into the code to help out with
> these problems. Maybe it would then be time to obtain CVS write
> permission.

ditto.

> 
> :) Christoph

:) Christoph

Re: Pittfalls in migration from WM to VL

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Christoph Reck wrote:

[snip]
 
> * Escaping some reference within a parsed template is not
>   respected. Add the follwing line to test/templates/parse.vm
>   and parse1.vm and see the difference...
>     \$list is a $list.Class.Name with length $list.size()
> 

This one I proudly found also in front of a client :)

> * More problems with method invocations (also see turbine list
>   message "Scheduler") following example does not work:
>     #set $foo = $list.set(0, "ArrayList element x")
>     Changed first element from "$foo" to "$list.get(0)"

Yes, it seems ArrayList introspection has a problem.

> 
> >[snip]
> > * A #set with a following comment causes a NPE, e.g:
> >   #set $color = "0x8080FF" ## light blue
> 
> still there...
> >[from another thread to this subject]
> > > Currently, the #set is to be kept alone on its own line.
> > >
> > > We are going to normalize the set directive :
> > >
> > >    #set( expression )
> > >
> > > to look like other directives, and then deprecate the current
> > > #set over time.
> Such a change would require voting. for me it's -1, even though
> my vote doesn't count (yet). I would like to be able to have
> all directives standalone each in its own line to keep them
> visually separate from the content (whithout them polluting
> the output - even of the #D's are indented). I don't see a reason
> for embedded #set directives. Well I would agree that if a
> #set() is used to create context objects, then a #macro should
> also...

Oh. Sorry.  It has been discussed for quite a while and wasn't a
unilateral move on my part.  It's an effort to get the directive's
normalized.  Currently, #set is an exception, as every other directive
is of the form #<directive>()

And I don't understand the -1 if the only reason is that you want it
standalone.  You can just as 
easily do 

#set( $foo = $bar)

or 

#set( $foo = $bar )  ## comment

It's called an 'inline set' because you CAN use it inline in VTL (ex 
blargh #set($i=$b) blargh), not because you MUST.

So please clarify your opposition.


> > * A file ending in a ## without an EOL emits a TokenMgrError.
> 
> still there...

I know, but it's not as simple as you think. I assume you work under
some flavor of Windows?

I managed to create a template that causes the bug only on a window
box.  Since it is apparently holding you up, I will get to that today
too if I can recreate it on my linux box using that input file.

What happens if you put a newline after the ##?  Would that remove this
as a showstopper to your development?

> 
> > * A #set without an "=" emits a NPE instead of an apropiate
> >   error message.
> 
> still there...

Yep.  Didn't go after that yet.

> 
> > * The negation in #if ( !$foo )
> 
> fixed..

I am not sure there actually was a problem.

> 
> > * A method invocation (which is not a getXXX) without parameters
> >   requires an empty braket set, else it throws a ClassCastException,
> >   e.g. add following line to the example.vm: length=$list.size
> 
> still there...
> 
> > * A null assignment (e.g. returned from a method call) leaves the
> >   variable unchanged, e.g:
> 
> still there...
> Here a better example for the test templates:
> 
>   #set $foo = ""
>   The contents of foo after "\#set \$foo = \$list.get(0)" is:
>   #set $foo = $list.get(0)
>   $foo
> 
>   Getting element 5 should return null
>   So what's in foo after "\#set \$foo = \$list.get(5)":
>   #set $foo = $list.get(5)
>   #if ( $foo )
>     \$foo should have contained NULL (has "$foo")!
>   #else
>     $foo is now correctly NULL.
>   #end

See ArrayList introspection comment above.
 
> >
> > * Hastables are known to a foreach, but not to set. The WM syntax
> >   #set $provider.Hashtable.NEW_KEY = "a string"
> >   does not do anyting. How does one set a value into a Hastable without
> >   emitting the previous content? does one need to do:
> >   #set $dummy = $provider.Hashtable.put("NEW_KEY", "a string")
> 

Come on....  Velocity isn't going to police the context and somehow
divine your intent....  The objects you put into the context do what
they do.  

> 
> >
> > * Whitespaces around standalone #if, #else, #end are preserved,
> >   it should be possible to handle them like a #set
> >[snip]
> > * Pluggable directives should contain a flag on the interface that
> >   states if whitespaces should be removed when these are standalone.
> >   A #parse should not touch whitespaches, whereas a #include should
> 
> still not there...
> 
> > > So directives don't emit the EOL, but they will produce the whitespace
> > > on the left.
> 
> Why is the following emmitting two EOLs between the output lines?

There's a bug!  You are right. It shouldn't be there.  Fixed.

[snip]

> >
> > * The current snapshot contains new xalan/xerces which is not
> >   compatible with the included JTest.
> 
> still there... 'build-velocity.sh test' does not work.

Is that the reason?  are you on a windows box?

> >
> > * The example/test.sh in the current snapshot is referencing
> >   velocity-0.4.jar instead of the generated 0.5
> 
> fixed.

can't wait for the flood of messages when you notice it's now 0.71

> >[from other mail in the same thread:
> > 1. How can I define reference to a string containing a quote: e.g.:
> >      #set $width=" width=\"$value.getAttributeValue("width")\""
> >    is this escaping within a string possible?
> (note that I made a similar question with allowing mixing single
>  and double quotes in another thread).

Yes, you are 100% on the money here.  We need to esacpe " in strlits.
 
> Related to this: are multiline strings possible somehow? e.g.:
> #set $xmlString = "<xml>
>   <item value='123'>
> </xml>"

No
 
> >
> > Please let me know if I should dig into the code to help out with
> > these problems. Maybe it would then be time to obtain CVS write
> > permission.
> 
> ditto.
> 
> >
> > :) Christoph
> 
> :) Christoph

-- 
Geir Magnusson Jr.                               geirm@optonline.com

Re: Pittfalls in migration from WM to VL

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Christoph Reck wrote:

> > * A #set without an "=" emits a NPE instead of an apropiate
> >   error message.

Are you sure?  For me, 

#set $foo = "hi"
#set $bar $foo

generates a ParserException in the log.

I guess you will see a NPE when the merging the template is tried...  We
can catch that.

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.com

Re: Pittfalls in migration from WM to VL

Posted by Christoph Reck <Ch...@dlr.de>.
"Geir Magnusson Jr." wrote:
> 
> Christoph Reck wrote:
> >
> > Many of the bugs are still in there. It is keeping me from
> > moving from WM to V. I'm reaching the point where I cannot
> > continue, since I need VMs.
> 
> Let me ask the obvious : how can bugs in the Velocity implementation of
> Velocimacros be stopping you from moving from WebMacro?  WebMacro has no
> Velocimacro-like facilities...

It is not the "Velocity implementation of Velocimacros" that is 
currently stopping the show. It is the listed bugs (specifically
the introspection problems thats the show-stopper...

I can/have ported from VM to VL (== Velocity [answer to other thread])
But the listed bugs keep it from working. Only some of them
have workarounds (e.g. removing comments after #set's, adding a EOL 
after a termial ##, etc.).


So now I'll proceed with the obvious as Jon Stevens stated:
> >> Please let me know if I should dig into the code to help out with
> >> these problems. Maybe it would then be time to obtain CVS write
> >> permission.
> 
> We shouldn't have to tell you that. :-)
> 
> And, you don't need CVS write to submit patches.

I just wanted to avoid working on something that is currently beeing
worked on...

I will now attack the introspection issue.

:) Christoph

Re: Pittfalls in migration from WM to VL

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Christoph Reck wrote:
> 
> Many of the bugs are still in there. It is keeping me from
> moving from WM to V. I'm reaching the point where I cannot
> continue, since I need VMs.

Let me ask the obvious : how can bugs in the Velocity implementation of
Velocimacros be stopping you from moving from WebMacro?  WebMacro has no
Velocimacro-like facilities...

?

geir


> I detected two more buglet...
> 
> * Escaping some reference within a parsed template is not
>   respected. Add the follwing line to test/templates/parse.vm
>   and parse1.vm and see the difference...
>     \$list is a $list.Class.Name with length $list.size()
> 
> * More problems with method invocations (also see turbine list
>   message "Scheduler") following example does not work:
>     #set $foo = $list.set(0, "ArrayList element x")
>     Changed first element from "$foo" to "$list.get(0)"
> 
> >[snip]
> > * A #set with a following comment causes a NPE, e.g:
> >   #set $color = "0x8080FF" ## light blue
> 
> still there...
> 
> >[from another thread to this subject]
> > > Currently, the #set is to be kept alone on its own line.
> > >
> > > We are going to normalize the set directive :
> > >
> > >    #set( expression )
> > >
> > > to look like other directives, and then deprecate the current
> > > #set over time.
> Such a change would require voting. for me it's -1, even though
> my vote doesn't count (yet). I would like to be able to have
> all directives standalone each in its own line to keep them
> visually separate from the content (whithout them polluting
> the output - even of the #D's are indented). I don't see a reason
> for embedded #set directives. Well I would agree that if a
> #set() is used to create context objects, then a #macro should
> also...
> 
> > * A file ending in a ## without an EOL emits a TokenMgrError.
> 
> still there...
> 
> > * A #set without an "=" emits a NPE instead of an apropiate
> >   error message.
> 
> still there...
> 
> > * The negation in #if ( !$foo )
> 
> fixed..
> 
> > * A method invocation (which is not a getXXX) without parameters
> >   requires an empty braket set, else it throws a ClassCastException,
> >   e.g. add following line to the example.vm: length=$list.size
> 
> still there...
> 
> > * A null assignment (e.g. returned from a method call) leaves the
> >   variable unchanged, e.g:
> 
> still there...
> Here a better example for the test templates:
> 
>   #set $foo = ""
>   The contents of foo after "\#set \$foo = \$list.get(0)" is:
>   #set $foo = $list.get(0)
>   $foo
> 
>   Getting element 5 should return null
>   So what's in foo after "\#set \$foo = \$list.get(5)":
>   #set $foo = $list.get(5)
>   #if ( $foo )
>     \$foo should have contained NULL (has "$foo")!
>   #else
>     $foo is now correctly NULL.
>   #end
> 
> >
> > * Hastables are known to a foreach, but not to set. The WM syntax
> >   #set $provider.Hashtable.NEW_KEY = "a string"
> >   does not do anyting. How does one set a value into a Hastable without
> >   emitting the previous content? does one need to do:
> >   #set $dummy = $provider.Hashtable.put("NEW_KEY", "a string")
> 
> still there...
> 
> >
> > * Whitespaces around standalone #if, #else, #end are preserved,
> >   it should be possible to handle them like a #set
> >[snip]
> > * Pluggable directives should contain a flag on the interface that
> >   states if whitespaces should be removed when these are standalone.
> >   A #parse should not touch whitespaches, whereas a #include should
> 
> still not there...
> 
> > > So directives don't emit the EOL, but they will produce the whitespace
> > > on the left.
> 
> Why is the following emmitting two EOLs between the output lines?
> ---
> Testing it:
> #if ($condition)
>     The condition is true!
> #else
>     The condition is false or is not set!!
> #end
> ---
> outputs:
> ---
> Testing it:
> 
>     The condition is false or is not set!!
> ---
> 
> I would like to be able to have directives standalone each
> in its own line to keep them visually separate from the content
> (whithout them polluting the output - even of these are indented).
> 
> >
> > * The current snapshot contains new xalan/xerces which is not
> >   compatible with the included JTest.
> 
> still there... 'build-velocity.sh test' does not work.
> 
> >
> > * The example/test.sh in the current snapshot is referencing
> >   velocity-0.4.jar instead of the generated 0.5
> 
> fixed.
> 
> >
> > * The build-velocity.sh just does a prepare as the default target,
> >   I would expect it to do at least a compile and jar (as the
> >   install.html states).
> 
> fixed.
> 
> >[from other mail in the same thread:
> > 1. How can I define reference to a string containing a quote: e.g.:
> >      #set $width=" width=\"$value.getAttributeValue("width")\""
> >    is this escaping within a string possible?
> (note that I made a similar question with allowing mixing single
>  and double quotes in another thread).
> 
> Related to this: are multiline strings possible somehow? e.g.:
> #set $xmlString = "<xml>
>   <item value='123'>
> </xml>"
> 
> >
> > Please let me know if I should dig into the code to help out with
> > these problems. Maybe it would then be time to obtain CVS write
> > permission.
> 
> ditto.
> 
> >
> > :) Christoph
> 
> :) Christoph

-- 
Geir Magnusson Jr.                               geirm@optonline.com

Re: Pittfalls in migration from WM to VL

Posted by Jon Stevens <jo...@latchkey.com>.
on 12/6/2000 6:09 AM, "Christoph Reck" <Ch...@dlr.de> wrote:

>> Please let me know if I should dig into the code to help out with
>> these problems. Maybe it would then be time to obtain CVS write
>> permission.

We shouldn't have to tell you that. :-)

And, you don't need CVS write to submit patches.

thanks,

-jon