You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Daigo Kobayashi <da...@abs-network.com> on 2005/11/05 10:14:18 UTC

merge directive

 I create merge directive. It's mainly use code generation.
I want to contribute this directive. So please teach me how
contribute this code.

I explain how merge directive work as follows,
#merge("foo.xml" "bar")
    //default template
#end

foo.xml structure is like this
<?xml version="1.0" encoding="UTF-8"?>
<velocity-merge>
<content name="bar"><![CDATA[some contents]]></content>
<content name="bar2"><![CDATA[ some contents]]></content>
</velocity-merge>

 First merge directive parse foo.xml file and search name="bar"
element. If it found, merge directive write content of that element
and jump to end. (i.e. This case merge directive write "some contents")
If it not found, merge directive write default template.

 I assume this directive use code generation. Velocity doesn't consider
overwrite problem. If we generate code over and over, then velocity
overwrite it every time. So I consider merge directive. We add special
comment to template.

created code:
public void foo () {
//velocity-merge %foo% start
    //Developer
    //write
    //implementation.
//velocity-merge %foo% end
}

template:
public void foo() {
//velocity-merge %foo% start
#merge("foo.xml" "foo")
    //TODO You should implement this method.
#end
//velocity-merge %foo% end
}

 Before we generate code, we parse source code and create foo.xml file.
(I also create this tool, and also contribute this tool.) Then velocity
create code and merge developer's implementation.

Please, no flames about my bad English.

Sincerely,
Daigo Kobayashi


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


pairing for some velocity patches

Posted by Llewellyn Falco <is...@setgame.com>.
Hey will,

    i know we talked about a quick 1 hour session of pairing to get some 
patches created and into velocity a few weeks back, then you we busy with a 
wedding, and i got called off to france, but back now and would really like 
to be able to get some of these issues into the 1.5 release. I Know that's 
coming soon, soon i'll try to open any time you have to do a bit of work.

    tell me when, and we'll set it up.

    llewellyn falco. 


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


opps.

Posted by Llewellyn Falco <is...@setgame.com>.
sorry list, meant to reply directly to will....

    llewellyn.

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


Re: merge directive

Posted by Daigo Kobayashi <da...@abs-network.com>.
I make MergeDirective on velocity-tools contributed code section.
Please check that.

Best Regards,
Daigo Kobayashi

> I suggest you make a page on the Wiki in the "Contributed Code" section 
> and include your example.
> 
> WILL


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


Re: merge directive

Posted by Will Glass-Husain <wg...@forio.com>.
I suggest you make a page on the Wiki in the "Contributed Code" section and 
include your example.

WILL

----- Original Message ----- 
From: "Daigo Kobayashi" <da...@abs-network.com>
To: "Velocity Developers List" <ve...@jakarta.apache.org>
Sent: Saturday, November 05, 2005 10:29 PM
Subject: Re: merge directive


> Hi Will,
>
> Thank you for replay my message.
>
>> I'm not quite sure I understand how this will be used.  Can you give a
>> specific example?  Is "foo.xml" a source file or an output file?
>
> "foo.xml" is source file.
>
> I create small example. How do I send this sample?(I create example
> using eclipse.)
>
>> Also, have you looked at Anakia?  I'm wondering if that serves some of
>> the same purpose.  It parses an XML file and lets you generate a
>> Velocity document based on that.
>
> Actually it serves some of the same purpose. However, #merge directive
> aimed mainly incremental code generation. I think anakia is aimed
> static code generation such as HTML, static structured XML and so on.
> When we use code generator, if we don't have any way to merge
> implemented code, we have to use generation gap pattern or hook
> operation pattern to avoid artifact lost. But some case (for example
> using xdoclet or annotation) generation gap and hook operation pattern
> is useless. Also both pattern generate too many classes. Therefore I
> create merge directive.
>
> Best Regards,
> Daigo Kobayashi
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
> 


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


Re: merge directive

Posted by Daigo Kobayashi <da...@abs-network.com>.
Hi Will,

Thank you for replay my message.

> I'm not quite sure I understand how this will be used.  Can you give a 
> specific example?  Is "foo.xml" a source file or an output file?

 "foo.xml" is source file.

 I create small example. How do I send this sample?(I create example
using eclipse.)

> Also, have you looked at Anakia?  I'm wondering if that serves some of 
> the same purpose.  It parses an XML file and lets you generate a 
> Velocity document based on that.

Actually it serves some of the same purpose. However, #merge directive
aimed mainly incremental code generation. I think anakia is aimed
static code generation such as HTML, static structured XML and so on.
 When we use code generator, if we don't have any way to merge
implemented code, we have to use generation gap pattern or hook
operation pattern to avoid artifact lost. But some case (for example
using xdoclet or annotation) generation gap and hook operation pattern
is useless. Also both pattern generate too many classes. Therefore I
create merge directive.

Best Regards,
Daigo Kobayashi



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


Re: merge directive

Posted by Will Glass-Husain <wg...@forio.com>.
Hi Diago,

Thanks for offering to contribute.  No flames on your English -- if we have 
trouble understanding we'll just ask questions!
The best place to contribute this might be on our Wiki.  There's a section 
for contributed code.  But we'd be glad to discuss on the list.

I'm not quite sure I understand how this will be used.  Can you give a 
specific example?  Is "foo.xml" a source file or an output file?

Also, have you looked at Anakia?  I'm wondering if that serves some of the 
same purpose.  It parses an XML file and lets you generate a Velocity 
document based on that.

Best, WILL

----- Original Message ----- 
From: "Daigo Kobayashi" <da...@abs-network.com>
To: <ve...@jakarta.apache.org>
Sent: Saturday, November 05, 2005 1:14 AM
Subject: merge directive


> I create merge directive. It's mainly use code generation.
> I want to contribute this directive. So please teach me how
> contribute this code.
>
> I explain how merge directive work as follows,
> #merge("foo.xml" "bar")
>    //default template
> #end
>
> foo.xml structure is like this
> <?xml version="1.0" encoding="UTF-8"?>
> <velocity-merge>
> <content name="bar"><![CDATA[some contents]]></content>
> <content name="bar2"><![CDATA[ some contents]]></content>
> </velocity-merge>
>
> First merge directive parse foo.xml file and search name="bar"
> element. If it found, merge directive write content of that element
> and jump to end. (i.e. This case merge directive write "some contents")
> If it not found, merge directive write default template.
>
> I assume this directive use code generation. Velocity doesn't consider
> overwrite problem. If we generate code over and over, then velocity
> overwrite it every time. So I consider merge directive. We add special
> comment to template.
>
> created code:
> public void foo () {
> //velocity-merge %foo% start
>    //Developer
>    //write
>    //implementation.
> //velocity-merge %foo% end
> }
>
> template:
> public void foo() {
> //velocity-merge %foo% start
> #merge("foo.xml" "foo")
>    //TODO You should implement this method.
> #end
> //velocity-merge %foo% end
> }
>
> Before we generate code, we parse source code and create foo.xml file.
> (I also create this tool, and also contribute this tool.) Then velocity
> create code and merge developer's implementation.
>
> Please, no flames about my bad English.
>
> Sincerely,
> Daigo Kobayashi
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-dev-help@jakarta.apache.org
> 


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