Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » JET2 - invoking with a different input file.
JET2 - invoking with a different input file. [message #9905] Tue, 03 April 2007 21:51 Go to next message
Eclipse User
Originally posted by: evaandoli.dodo.com.au

Hi,

I call JET2 within my project passing fileA.
In the transformation I'd like to invoke the same project but passing a file
that is specified in fileA.

I have looked at the <c:invoke> call but can't see where I can change the
input file.
I have tried setting the variable
var="org.eclipse.jet.resource.fileName"

before the invoke but no joy (also not sure if I should really change this
in the parent transformation anyway.

Thanks for any help,

At the moment my solution is to have separate RUN. . . with different
inputs - so far im up to 6 "woo hoo".

Stu
Re: JET2 - invoking with a different input file. [message #9999 is a reply to message #9905] Wed, 04 April 2007 09:14 Go to previous message
Paul Elder is currently offline Paul Elder
Messages: 849
Registered: July 2009
Senior Member
Stu:

As you have noticed, c:invoke doesn't load a model for you - it passes the
current context on to the invoked transformation. In particular, this means
that the invoked transformation receives all the XPath variables from the
invoking transformation, and, in particular, it receives the same XPath root
object. (Yes, this is a bit weird.)

You can use the c:load tag to load a model (and get an XPath variable to the
model root).

Then, you could then use c:invoke to invoke your transformation. The
transformation would have to look for this variable, and set its XPath root
object to the loaded model. There is no Tag to do this, you'd have to write
a bit of Java in main.jet:

<%
// do this at the start of main.jet
Object savedSource = null;
if(context.hasVariable("yourMagicVariable")) {
savedSource = context.getSource();
context.setSource(context.getVariable("yourMagicVariable"));
}
%>

.... body of main.jet

<%
// do this at the end of main.jet - resource the source object
if(savedSource != null) {
context.setSource(savedSource);
}
%>

Less than beautiful, but it should do the job.

Paul

"Stu" <evaandoli@dodo.com.au> wrote in message
news:euv0af$d7d$1@build.eclipse.org...
> Hi,
>
> I call JET2 within my project passing fileA.
> In the transformation I'd like to invoke the same project but passing a
> file that is specified in fileA.
>
> I have looked at the <c:invoke> call but can't see where I can change the
> input file.
> I have tried setting the variable
> var="org.eclipse.jet.resource.fileName"
>
> before the invoke but no joy (also not sure if I should really change this
> in the parent transformation anyway.
>
> Thanks for any help,
>
> At the moment my solution is to have separate RUN. . . with different
> inputs - so far im up to 6 "woo hoo".
>
> Stu
>
>
Previous Topic:Dynamic parameter for a java method defined in the jet file
Next Topic:Re: Suppress rather than override static JET templates
Goto Forum:
  


Current Time: Fri Aug 29 04:09:12 EDT 2014

Powered by FUDForum. Page generated in 0.01946 seconds