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/11/23 11:32:05 UTC

Pittfalls in migration from WM to VL

Here I'll list problems that I encountered in migrating the
templates (I hope such a alpha test result list is welcome):

* convert.WebMacro is not up to date and makes to many
  assumptions. 
  + I will send a patch.
  - a #begin is not removed if it is in the same "#if" line
  - converting to "#foreach ($foo in $bar).getKeys()"
  - #parse still converted to #include (w/o parenthesis)
  - javascript "}"s being converted to #end (this is maybe out
    of scope of the simple convert.WebMacro)

* Variables starting with a "_" underscore are not converted
  - should be allowed and added to the VL grammar.

* Template error messages are emitted without stating the filename 
  and wrong line numbers when using #parse.
  + In general template error messages are not very helpfull. I will 
    try to provide patches when I get to it.

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

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

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

* The negation in #if ( !$foo ) does not work (throws a NPE if
  $foo does not exist). 
  + workaround use: #if ( $foo )#else ...
  - The test/template/logical.wm has a #if (!($foo == true)), but
    just shows that the negation works with logical values.

* 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

* A null assignment (e.g. returned from a method call) leaves the
  variable unchanged, e.g:
  #set $foo = "bar"
  \$foo is now $foo
  #set $foo = $provider.Hashtable.get("anything not in there")
  #if ( $foo )
    \$foo should have contained null!
  #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")

* Whitespaces around standalone #if, #else, #end are preserved,
  it should be possible to handle them like a #set
  - Note that this would also make the VSL templates much more
    readable!
  ---
  #set $bar = true
  #if ($foo)
      \$foo=>$foo
  #else    $foo undefined
    #if ($bar)
      \$bar=>$bar
    #else
      $bar undefined
    #end
  #end
  ---
  should emit
  ---
      $foo undefined
      $bar=>true
  ---
  where the first else is not standalone, therefore whitespaces 
  are untouched, all other directives (even the indented ones)
  emit nothing (not even a EOL).
  
* 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 
  in my opinion work, e.g.:
     #set $data.Response.setHeader("content-type", "image/gif")
     #set $dummy = $data.getOut()
     #include ("/images/logo.gif")

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

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

* 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).


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.


:) Christoph

Re: Error in latest CVS: TexenTask.java

Posted by Jason van Zyl <jv...@periapt.com>.
On Fri, 24 Nov 2000, Jason van Zyl wrote:

> On Fri, 24 Nov 2000, Randall G. Alley wrote:
> 
> Sorry, I fixed that and didn't commit it. I'll do it now.
> Thanks for catching that!

Fixed.

-- 
jvz.

Jason van Zyl
jvanzyl@periapt.com


Re: Error in latest CVS: TexenTask.java

Posted by Jason van Zyl <jv...@periapt.com>.
On Fri, 24 Nov 2000, Randall G. Alley wrote:

Sorry, I fixed that and didn't commit it. I'll do it now.
Thanks for catching that!

> Trying to compile this morning I found:
> 
>     [javac] Compiling 1 source file to D:\Jakarta\jakarta-velocity\bin\classes
>     [javac]
> D:\Jakarta\jakarta-velocity\bin\src\org\apache\velocity\texen\ant\TexenTask.java:24
> 
> 4: ';' expected.
>     [javac]     public Context initControlContext
>     [javac]                                      ^
>     [javac] 1 error
> 
> Looking up line 244:
>     public Context initControlContext
>     {
>     }
> 
> 
> No Context object is returned. Also should syntax be like:
> 
>     public Context initControlContext()
>     {
>         // return proper context object
>     }
> 
> 
> Thanks,
> Randy
> 
> 

-- 
jvz.

Jason van Zyl
jvanzyl@periapt.com


Error in latest CVS: TexenTask.java

Posted by "Randall G. Alley" <ir...@bellsouth.net>.
Trying to compile this morning I found:

    [javac] Compiling 1 source file to D:\Jakarta\jakarta-velocity\bin\classes
    [javac]
D:\Jakarta\jakarta-velocity\bin\src\org\apache\velocity\texen\ant\TexenTask.java:24

4: ';' expected.
    [javac]     public Context initControlContext
    [javac]                                      ^
    [javac] 1 error

Looking up line 244:
    public Context initControlContext
    {
    }


No Context object is returned. Also should syntax be like:

    public Context initControlContext()
    {
        // return proper context object
    }


Thanks,
Randy


Re: Pittfalls in migration from WM to VL

Posted by Fedor Karpelevitch <fe...@home.com>.
I am also for leaving "-" as a valid char. I do not care for "_" much.
Just my 2c.

Daniel Rall wrote:

> Christoph Reck <Ch...@dlr.de> writes:
> 
> 
>> replying to Geir's response (without a copy to velocity-user):
>> 
>>> That was a decision made a while ago. It's easy to fix if enough people
>>> think it's a good idea.  It would make our identifiers conform a little
>>> better to the java spec. (Can we please get rid of the '-' as an
>>> acceptable identifier character? How many people are going to regularly
>>> use 'working-dogs' as a reference, jon? :)
>> 
>> I raised this earlyer and jvz stated that it could be made it this was
>> really a "standard" and people want it (up to now I'm the only one that
>> has spoken up).
>> 
>> It would be great if you allow the "_" at the beginning of a variable.
>> 
>> +1 to get rid of the "-".
> 
> 
> I think that the "-" as a valid variable name character should stay.
> It is very standard, and LISPers do in fact use it heavily.
> 
> Daniel


Re: Pittfalls in migration from WM to VL

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Christoph Reck <Ch...@dlr.de> writes:

> replying to Geir's response (without a copy to velocity-user):
> > That was a decision made a while ago. It's easy to fix if enough people
> > think it's a good idea.  It would make our identifiers conform a little
> > better to the java spec. (Can we please get rid of the '-' as an
> > acceptable identifier character? How many people are going to regularly
> > use 'working-dogs' as a reference, jon? :)
> 
> I raised this earlyer and jvz stated that it could be made it this was
> really a "standard" and people want it (up to now I'm the only one that
> has spoken up).
> 
> It would be great if you allow the "_" at the beginning of a variable.
> 
> +1 to get rid of the "-".

I think that the "-" as a valid variable name character should stay.
It is very standard, and LISPers do in fact use it heavily.

Daniel

Re: Pittfalls in migration from WM to VL

Posted by Christoph Reck <Ch...@dlr.de>.
replying to Geir's response (without a copy to velocity-user):

>[snip]
> >
> > * Variables starting with a "_" underscore are not converted
> >   - should be allowed and added to the VL grammar.
> 
> That was a decision made a while ago. It's easy to fix if enough people
> think it's a good idea.  It would make our identifiers conform a little
> better to the java spec. (Can we please get rid of the '-' as an
> acceptable identifier character? How many people are going to regularly
> use 'working-dogs' as a reference, jon? :)

I raised this earlyer and jvz stated that it could be made it this was
really a "standard" and people want it (up to now I'm the only one that
has spoken up).

It would be great if you allow the "_" at the beginning of a variable.

+1 to get rid of the "-".

>[snip]
> > * A #set with a following comment causes a NPE, e.g:
> >   #set $color = "0x8080FF" ## light blue
> 
> Yes, currently the #set is standalone to help keep expression parsing
> reasonable, but this example should be doable.  

Great!

> On the same theme, how
> do people feel about changing to #set( expression ) ?  It will then
> conform to our directive syntax #<directive>( optional arg ) and be
> easier to put in-line in template code.  So you can do things like
> 
> #set($foo = $bar + 2) + 3 bears...
> 
> w/o any muss or fuss.  If people like this ( I do - its different but
> useful), we can put the new one in and try to deprecate the existing
> #set.

I don't believe #sets should be done inline, look how ugly:
#if (!$foo) #set $message = "foo is not defined" #end
(now will this emit whitespace or an EOL?)

>[snip]
> > * Whitespaces around standalone #if, #else, #end are now preserved,
> >   it should be possible to handle them like a #set
> >   - Note that this would also make the VSL templates much more
> >     readable!
I placed further below an example of the site.vsl
> >   ---
> >   #set $bar = true
> >   #if ($foo)
> >       \$foo=>$foo
> >   #else    $foo undefined
> >     #if ($bar)
> >       \$bar=>$bar
> >     #else
> >       $bar undefined
> >     #end
> >   #end
> >   ---
> >   should emit
> >   ---
> >       $foo undefined
> >       $bar=>true
> >   ---
> >   where the first else is not standalone, therefore whitespaces
> >   are untouched, all other directives (even the indented ones)
> >   emit nothing (not even a EOL).
> 
> It does emit that, except for the two spaces before $bar=>true because
> you have the #if indented.
> 
> The current behavior was a conscious decision, not an accident, and was
> presented to the group with both an announcement as well as examples in
> the testbed.  The point is to balance between readable templates and
> controllable output.  It has been argued that whitespace should be
> collapsed on the LHS of a standalone directive.  Currently, whitespace
> is collapsed on the RHS.

I was one of the reviewers, I was waiting for VL to be ready for testing
to see the real impact. The examples in the review did not contain
indented #ifs!

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

Bad.

> 
> I'll take a whack at fixing that.

Good.

> 
> I had some example of where one would want this, but I forget now :)  We
See jon's anaki VSL templates!
> always have to make sure that all outputs are supported w/o excessive
> contortions on the part of the template writer (in my opinion.)

Take a look at jon's anaki VSL templates an tell me these look nice ;)

Directives should be transparent to the data, therefore if the writer
puts these into own lines (to visually separate them from the code)
and indent them when nested, the whole line should not emit anything.

When directives are inline, they should respect any whitespace around
them.

Jon's templates would look nicer, e.g. compare to the original site.vsl:
#macro ( image $value )
  #if ($value.getAttributeValue("width"))
    #set $width=$value.getAttributeValue("width")
  #end
  #if ($value.getAttributeValue("height"))
    #set $height=$value.getAttributeValue("height")
  #end
  #if ($value.getAttributeValue("align"))
    #set $align=$value.getAttributeValue("align")
  #end
<img src="$relativePath$value.getAttributeValue("src")"##
 width="$!width" height="$!height" align="$!align">
#end
## note that the EOL within the <img...> was escaped with a line comment!
## even a cleaner example further below...

BTW:
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?
2. What happens to the localy defined variables $height, $width
   after the macro returns? Can I have the macro set/change global
   references?

> 
> >
> > * 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
> >   in my opinion work, e.g.:
> >     #set $data.Response.setHeader("content-type", "image/gif")
> >     #set $dummy = $data.getOut()
> >     #include ("/images/logo.gif")
> 
> That is incompatible with your previous argument, I think.   (I assume
> that you mean not the action of the PD, but rather the whitespaces pre
> or post the #<dir>() syntactical element.)
(assumption correct)

I would like to call macros and parse without stripping leading
whitespaces:
  <table>
    <tr>
     #foreach ($td in $tableData)
      <td>
        #set $indent = "        "
        #formatTableData($td, $indent)
      </td>
    </tr>
  </table>
So in this example the macro can indent any continuation line
accordingly.

> 
> I don't agree : I think that they all directives should behave the same
> WRT LHS and RHS whitespace/newline gobbling.  Lets keep things simple.
> You can achieve the above my simply removing what I interpret are two
> spaces before the include.  So.

Sorry, but the real world formatting is not *that* simple :)

> 
> #set $data.Response.setHeader("content-type", "image/gif")
> #set $dummy = $data.getOut()
> #include ("/images/logo.gif")
> 
> should give you the correct output

But what about:
## file: dumpText.vm
#set $filename = $data.Request.getString("filename", "")
#if ($filename == "")
  #call $data.setMessage("no file specified")
#else
  #set $data.Response.setHeader("content-type", "plain/text")
  #set $file = $data.ServletContext.getRealPath($l_fileName)
  #include($file)
#end
This is a nicely formatted template. For parse and macro as 
previous example it is desireable to conserve whitespaces,
whereas set, include, foreach, stop, etc. shall not!

The only problem is when you explicetely want to crop leading
white spaces (due to pretty template formatting), which can be 
done as (above vsl extract example simplified):
#macro ( attribute $node, $name )
  #set $value = $node.getAttributeValue("$name")
  #if ($value)#*
    *# $name="$value"##
  #end
#end
#macro ( image $value )
<img src="$relativePath$value.getAttributeValue("src")"#*
  *# border="0"#*
  *##attribute($value, "width")#* 
  *##attribute($value, "height")#* 
  *##attribute($value, "align")>
#end
And obtain beautifully formated output (avoiding the attributes
that have not been specified!). Note that VL comments #* ... *#
where used to escape EOL and leading spaces. (Will the *## cause
problems to the parser?)

> 
> I will be back friday afternoon to dig into this pile!  (Thanksgiving
> holiday here...)
> 
> Happy Thanksgiving.

Happy turkey day!
(here in Italy/Germany it is not celebrated).

> 
> geir

:) Christoph

Re: Pittfalls in migration from WM to VL

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
[cc-ing vel dev]

Good list! Rest inline, mostly about parser issues that I am currently
juggling :

Christoph Reck wrote:
> 
[snip]
> 
> * Variables starting with a "_" underscore are not converted
>   - should be allowed and added to the VL grammar.

That was a decision made a while ago. It's easy to fix if enough people
think it's a good idea.  It would make our identifiers conform a little
better to the java spec. (Can we please get rid of the '-' as an
acceptable identifier character? How many people are going to regularly
use 'working-dogs' as a reference, jon? :)

> * Template error messages are emitted without stating the filename
>   and wrong line numbers when using #parse.
>   + In general template error messages are not very helpfull. I will
>     try to provide patches when I get to it.

Yes, that's a whole bit I was meaning to get to.
 
> * A #set with a following comment causes a NPE, e.g:
>   #set $color = "0x8080FF" ## light blue


Yes, currently the #set is standalone to help keep expression parsing
reasonable, but this example should be doable.  On the same theme, how
do people feel about changing to #set( expression ) ?  It will then
conform to our directive syntax #<directive>( optional arg ) and be
easier to put in-line in template code.  So you can do things like 

#set($foo = $bar + 2) + 3 bears...

w/o any muss or fuss.  If people like this ( I do - its different but
useful), we can put the new one in and try to deprecate the existing
#set.

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

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

We can fix that in the parser or on the set code.

> [snip]
 
> * Whitespaces around standalone #if, #else, #end are preserved,
>   it should be possible to handle them like a #set
>   - Note that this would also make the VSL templates much more
>     readable!
>   ---
>   #set $bar = true
>   #if ($foo)
>       \$foo=>$foo
>   #else    $foo undefined
>     #if ($bar)
>       \$bar=>$bar
>     #else
>       $bar undefined
>     #end
>   #end
>   ---
>   should emit
>   ---
>       $foo undefined
>       $bar=>true
>   ---
>   where the first else is not standalone, therefore whitespaces
>   are untouched, all other directives (even the indented ones)
>   emit nothing (not even a EOL).

It does emit that, except for the two spaces before $bar=>true because
you have the #if indented.

The current behavior was a conscious decision, not an accident, and was
presented to the group with both an announcement as well as examples in
the testbed.  The point is to balance between readable templates and
controllable output.  It has been argued that whitespace should be
collapsed on the LHS of a standalone directive.  Currently, whitespace
is collapsed on the RHS.

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

I'll take a whack at fixing that.

I had some example of where one would want this, but I forget now :)  We
always have to make sure that all outputs are supported w/o excessive
contortions on the part of the template writer (in my opinion.)

> 
> * 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
>   in my opinion work, e.g.:
>     #set $data.Response.setHeader("content-type", "image/gif")
>     #set $dummy = $data.getOut()
>     #include ("/images/logo.gif")


That is incompatible with your previous argument, I think.   (I assume
that you mean not the action of the PD, but rather the whitespaces pre
or post the #<dir>() syntactical element.)

I don't agree : I think that they all directives should behave the same
WRT LHS and RHS whitespace/newline gobbling.  Lets keep things simple. 
You can achieve the above my simply removing what I interpret are two
spaces before the include.  So.

#set $data.Response.setHeader("content-type", "image/gif")
#set $dummy = $data.getOut()
#include ("/images/logo.gif")

should give you the correct output

I will be back friday afternoon to dig into this pile!  (Thanksgiving
holiday here...)

Happy Thanksgiving.

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Dakota tribal wisdom: "when you discover you are riding a dead horse,
the best strategy is to dismount."

Re: Pittfalls in migration from WM to VL

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
[cc-ing vel dev]

Good list! Rest inline, mostly about parser issues that I am currently
juggling :

Christoph Reck wrote:
> 
[snip]
> 
> * Variables starting with a "_" underscore are not converted
>   - should be allowed and added to the VL grammar.

That was a decision made a while ago. It's easy to fix if enough people
think it's a good idea.  It would make our identifiers conform a little
better to the java spec. (Can we please get rid of the '-' as an
acceptable identifier character? How many people are going to regularly
use 'working-dogs' as a reference, jon? :)

> * Template error messages are emitted without stating the filename
>   and wrong line numbers when using #parse.
>   + In general template error messages are not very helpfull. I will
>     try to provide patches when I get to it.

Yes, that's a whole bit I was meaning to get to.
 
> * A #set with a following comment causes a NPE, e.g:
>   #set $color = "0x8080FF" ## light blue


Yes, currently the #set is standalone to help keep expression parsing
reasonable, but this example should be doable.  On the same theme, how
do people feel about changing to #set( expression ) ?  It will then
conform to our directive syntax #<directive>( optional arg ) and be
easier to put in-line in template code.  So you can do things like 

#set($foo = $bar + 2) + 3 bears...

w/o any muss or fuss.  If people like this ( I do - its different but
useful), we can put the new one in and try to deprecate the existing
#set.

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

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

We can fix that in the parser or on the set code.

> [snip]
 
> * Whitespaces around standalone #if, #else, #end are preserved,
>   it should be possible to handle them like a #set
>   - Note that this would also make the VSL templates much more
>     readable!
>   ---
>   #set $bar = true
>   #if ($foo)
>       \$foo=>$foo
>   #else    $foo undefined
>     #if ($bar)
>       \$bar=>$bar
>     #else
>       $bar undefined
>     #end
>   #end
>   ---
>   should emit
>   ---
>       $foo undefined
>       $bar=>true
>   ---
>   where the first else is not standalone, therefore whitespaces
>   are untouched, all other directives (even the indented ones)
>   emit nothing (not even a EOL).

It does emit that, except for the two spaces before $bar=>true because
you have the #if indented.

The current behavior was a conscious decision, not an accident, and was
presented to the group with both an announcement as well as examples in
the testbed.  The point is to balance between readable templates and
controllable output.  It has been argued that whitespace should be
collapsed on the LHS of a standalone directive.  Currently, whitespace
is collapsed on the RHS.

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

I'll take a whack at fixing that.

I had some example of where one would want this, but I forget now :)  We
always have to make sure that all outputs are supported w/o excessive
contortions on the part of the template writer (in my opinion.)

> 
> * 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
>   in my opinion work, e.g.:
>     #set $data.Response.setHeader("content-type", "image/gif")
>     #set $dummy = $data.getOut()
>     #include ("/images/logo.gif")


That is incompatible with your previous argument, I think.   (I assume
that you mean not the action of the PD, but rather the whitespaces pre
or post the #<dir>() syntactical element.)

I don't agree : I think that they all directives should behave the same
WRT LHS and RHS whitespace/newline gobbling.  Lets keep things simple. 
You can achieve the above my simply removing what I interpret are two
spaces before the include.  So.

#set $data.Response.setHeader("content-type", "image/gif")
#set $dummy = $data.getOut()
#include ("/images/logo.gif")

should give you the correct output

I will be back friday afternoon to dig into this pile!  (Thanksgiving
holiday here...)

Happy Thanksgiving.

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Dakota tribal wisdom: "when you discover you are riding a dead horse,
the best strategy is to dismount."

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


Re: Pittfalls in migration from WM to VL

Posted by Christoph Reck <Ch...@dlr.de>.
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