Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsAny JET2 sample with Java object input ?
https://www.eclipse.org/forums/index.php/mv/msg/13145/41381/#msg_41381
Originally posted by: aah.yahoo.com
Hi,
I am looking for a JET2 sample, where the input is a live Java object --
which was described in JET1 tutorials published. I see that most of the
JET2 samples talk about a sample xml input and the template operates on
it using XPath.
Can someone please share some sample where input is a Java object?
Thanks in advance.
-Anand]]>2008-02-06T13:56:54-00:00Re: Any JET2 sample with Java object input ?
https://www.eclipse.org/forums/index.php/mv/msg/13145/41544/#msg_41544
If you are looking to manipulate Java objects directly, here are a few
suggestions.
1) To lauch a JET transformation, use
JET2Platform.runTransformationOnObject(), passing the object you want.
2) With-in a JET2 template, to access that object, use:
context.getSource().
(BTW, you can use Java scriptlets <% ...java statements ...%> and Java
expressions <%= expression %> within the template).
3) To write text from a scriptlet, use the 'out' variable.
If you can tell us a bit more about the context in which you want to use
JET, I can give you more hints.
Thanks,
Paul
"Anand" <aah@yahoo.com> wrote in message
news:foceb8$bg$1@build.eclipse.org...
> Hi,
> I am looking for a JET2 sample, where the input is a live Java object --
> which was described in JET1 tutorials published. I see that most of the
> JET2 samples talk about a sample xml input and the template operates on it
> using XPath.
>
> Can someone please share some sample where input is a Java object?
> Thanks in advance.
> -Anand]]>Paul Elder2008-02-07T16:35:10-00:00Re: Any JET2 sample with Java object input ?
https://www.eclipse.org/forums/index.php/mv/msg/13145/41604/#msg_41604
Originally posted by: anand.hatwalne.gmail.com
Paul, thanks for your reply.
I writing out some C++ code, by walking (parts of) the CDT AST.
So the input to my template would be a IASTTranslationUnit or
IASTCompositeTypeSpecifier object.
Using JET1, I figured out that it was as simple as passing the argument
to the template, and then play with that in the template.
I wasn't exactly sure how to achieve the same using JET2.
Here's a snippet from JET1 that I have put together. An analogy/example
with JET2 to achieve the same, would be really nice.
Paul Elder wrote the following on 2/7/2008 10:05 PM:
> Anand:
>
> If you are looking to manipulate Java objects directly, here are a few
> suggestions.
>
> 1) To lauch a JET transformation, use
> JET2Platform.runTransformationOnObject(), passing the object you want.
>
> 2) With-in a JET2 template, to access that object, use:
>
> context.getSource().
>
> (BTW, you can use Java scriptlets <% ...java statements ...%> and Java
> expressions <%= expression %> within the template).
>
> 3) To write text from a scriptlet, use the 'out' variable.
>
> If you can tell us a bit more about the context in which you want to use
> JET, I can give you more hints.
>
> Thanks,
>
> Paul
>
> "Anand" <aah@yahoo.com> wrote in message
> news:foceb8$bg$1@build.eclipse.org...
>> Hi,
>> I am looking for a JET2 sample, where the input is a live Java object --
>> which was described in JET1 tutorials published. I see that most of the
>> JET2 samples talk about a sample xml input and the template operates on it
>> using XPath.
>>
>> Can someone please share some sample where input is a Java object?
>> Thanks in advance.
>> -Anand
>
>]]>2008-02-08T04:00:38-00:00Re: Any JET2 sample with Java object input ?
https://www.eclipse.org/forums/index.php/mv/msg/13145/41758/#msg_41758
Apart form context.getSource(), you can also set JET2 context variables:
"Anand Hatwalne" <anand.hatwalne@gmail.com> wrote in message
news:fogk59$apb$1@build.eclipse.org...
> Paul, thanks for your reply.
>
> I writing out some C++ code, by walking (parts of) the CDT AST.
> So the input to my template would be a IASTTranslationUnit or
> IASTCompositeTypeSpecifier object.
>
> Using JET1, I figured out that it was as simple as passing the argument to
> the template, and then play with that in the template.
> I wasn't exactly sure how to achieve the same using JET2.
>
>
> Here's a snippet from JET1 that I have put together. An analogy/example
> with JET2 to achieve the same, would be really nice.
>
> <%@jet package="com.mypackage"
> imports="org.eclipse.cdt.core.dom.ast.* java.util.*"
> class="MyGenerator"
> %>
>
>
> <% IASTTranslationUnit translationUnit = (IASTTranslationUnit) argument;
> %>
>
>
> <%= Do Something here from the TU passed %>
>
>
> thanks again,
> Anand
>
> Paul Elder wrote the following on 2/7/2008 10:05 PM:
>> Anand:
>>
>> If you are looking to manipulate Java objects directly, here are a few
>> suggestions.
>>
>> 1) To lauch a JET transformation, use
>> JET2Platform.runTransformationOnObject(), passing the object you want.
>>
>> 2) With-in a JET2 template, to access that object, use:
>>
>> context.getSource().
>>
>> (BTW, you can use Java scriptlets <% ...java statements ...%> and Java
>> expressions <%= expression %> within the template).
>>
>> 3) To write text from a scriptlet, use the 'out' variable.
>>
>> If you can tell us a bit more about the context in which you want to use
>> JET, I can give you more hints.
>>
>> Thanks,
>>
>> Paul
>>
>> "Anand" <aah@yahoo.com> wrote in message
>> news:foceb8$bg$1@build.eclipse.org...
>>> Hi,
>>> I am looking for a JET2 sample, where the input is a live Java object --
>>> which was described in JET1 tutorials published. I see that most of the
>>> JET2 samples talk about a sample xml input and the template operates on
>>> it using XPath.
>>>
>>> Can someone please share some sample where input is a Java object?
>>> Thanks in advance.
>>> -Anand
>>]]>Paul Elder2008-02-13T15:44:36-00:00