Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » How to access the package and class name from the template?
How to access the package and class name from the template? [message #27908] Mon, 23 July 2007 06:11 Go to next message
Eclipse UserFriend
Originally posted by: technovator.gmail.com

Hi,

This is the portion from the main.jet that defines a java class:

<ws:project name="MyProject">
<ws:folder path="src">
<java:package name="com.example.jet">
<java:class name="Car" template="templates/dump.jet"/>
</java:package>
</ws:folder>
</ws:project>

Now in the template file dump.jet I want to get the class name and the
package name. How can I do this?

-- D
Re: How to access the package and class name from the template? [message #27948 is a reply to message #27908] Mon, 23 July 2007 19:01 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
D:

There is no mechanism to devine the package or the class name from
<java:package> and <java:class> tags, although it would be an intriguing
enhancement.

In real life situations, main.jet actions (such as java:package and
java:class) are driven by an input model. Typically, the values passed to
the name attributes of these actions are values stored in or derived from
that input model (using an embedded XPath expression). The template executed
by java:class would reference the same values.

Paul

"D" <technovator@gmail.com> wrote in message
news:4d37c4fe618b904ef76d5ff0e66ca04f$1@www.eclipse.org...
> Hi,
>
> This is the portion from the main.jet that defines a java class:
>
> <ws:project name="MyProject">
> <ws:folder path="src">
> <java:package name="com.example.jet">
> <java:class name="Car" template="templates/dump.jet"/>
> </java:package>
> </ws:folder>
> </ws:project>
>
> Now in the template file dump.jet I want to get the class name and the
> package name. How can I do this?
>
> -- D
>
>
>
Re: How to access the package and class name from the template? [message #28144 is a reply to message #27948] Tue, 24 July 2007 04:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: technovator.gmail.com

Paul:

Thanks.

It will be nice if some variables can be populated similar to the
org.eclipse.jet* variables populated. In that way the input model will be
accessed only in the main template.

-- D
Re: How to access the package and class name from the template? [message #28222 is a reply to message #28144] Tue, 24 July 2007 12:56 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
D:

I'm not sure I understand, can you expand on your idea a bit?

Thanks,

Paul
"D" <technovator@gmail.com> wrote in message
news:9aba59381e6869c2c4de0a6aa6ffb82f$1@www.eclipse.org...
> Paul:
>
> Thanks.
>
> It will be nice if some variables can be populated similar to the
> org.eclipse.jet* variables populated. In that way the input model will be
> accessed only in the main template.
>
> -- D
>
>
>
Re: How to access the package and class name from the template? [message #28297 is a reply to message #28222] Wed, 25 July 2007 10:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: technovator.gmail.com

Paul:

I am thinking of a case where the templates that generate content for
source files are generic and do not depend on the input model. This should
improve the reusability of these templates.

-- D
Re: How to access the package and class name from the template? [message #28335 is a reply to message #28297] Wed, 25 July 2007 12:48 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
D:

Ah, I get it, the template is much like a method. Ideally, it should declare
parameters, and accept values/expressions for those parameters when invoked.
Sounds like a good idea.

Paul


"D" <technovator@gmail.com> wrote in message
news:14cb920cd0c9df8236c01148e765594f$1@www.eclipse.org...
> Paul:
>
> I am thinking of a case where the templates that generate content for
> source files are generic and do not depend on the input model. This should
> improve the reusability of these templates.
>
> -- D
>
>
>
Previous Topic:Xpath and XMI format
Next Topic:JET FAQ How do I run an individual JET template and get a string back?
Goto Forum:
  


Current Time: Thu Mar 28 14:05:42 GMT 2024

Powered by FUDForum. Page generated in 0.03981 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top