Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » How to run a jet transformation in the plug-ins?
How to run a jet transformation in the plug-ins? [message #25687] Tue, 10 July 2007 17:31 Go to next message
hamlin is currently offline hamlinFriend
Messages: 8
Registered: July 2009
Junior Member
Hi guys,
I'm really new to the JET2 and I met some problems.

I created an EMFT JET transformation project (the id is
"my.jet.transformation") without any change and it worked perfectly via
the run JET Transformation dialog.

Then I created a test plug-in to execute the transformation. The running
result is very weird for it threw a "java.lang.NoClassDefFoundError:
org/eclipse/jet/JET2Platform" exception in JET2 0.7.1 while an error
message of "Variable "org.eclipse.jet.resource.project.name" is not
defined." in JET2 0.8.0 (during debuging).

My test code in the test plugin is quite simple:
...
IProgressMonitor monitor = new NullProgressMonitor();
String TRANS = "my.jet.transformation";
StringBuffer sb = readXML();
IStatus st = JET2Platform.runTransformOnString(TRANS,
sb.toString().trim(), monitor);
....

What shall I do then?

BTW, Is there any sample code or tutorial available for the freshman? I
found JET Tutorial Part 1 and 2 but it seems that they are introduction
for JET1.
Re: How to run a jet transformation in the plug-ins? [message #25945 is a reply to message #25687] Wed, 11 July 2007 13:14 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Chaohong:

The default transformation project has the following tag in main.jet:
<ws:file template="templates/dump.jet"
path="{$org.eclipse.jet.resource.project.name}/dump.xml"/>

This dumps the transformations input model to a file dump.xml in the root of
the project containing the input.

But, when you use runTransformOnString, there is not project containing the
input model. You have the following choices

1) remove the above tag

2) Change the {$org.eclipse.jet.resource.project.name} part to something
that is dependent on data in the model itself

3) Pass a value for org.eclipse.jet.resource.project.name into
runTransformOnString...

Map arguments = new HashMap();
arguments.put("org.eclipse.jet.resource.project.name", "Some Known Project
Name");
JET2Platform.runTransformOnString( transformID, yourXMLAsString, "xml",
variables, monitor);

As for articles and learning resourcs, they are still limited. Check out
these two articles:

http://www.devx.com/opensource/Article/34929?trk=DXRSS_LATES T

http://www.ibm.com/developerworks/opensource/library/os-ecl- jet/

Also, a JET FAQ is under construction, with the help of some of the members
of this group:

http://wiki.eclipse.org/M2T-JET-FAQ

And, of course, you can always ask a question on this group. Your question
has now been importalized:

http://wiki.eclipse.org/JET_FAQ_Why_do_I_get_errors_stating_ variable_%27org.eclipse.jet.resource.project.name%27_is_unde fined%3F

http://wiki.eclipse.org/JET_FAQ_What_learning_resources_are_ available_for_JET%3F

Paul


"Chaohong" <hamlinxie@gmail.com> wrote in message
news:8b6315917f2493c537b38942a6c28fc6$1@www.eclipse.org...
> Hi guys,
> I'm really new to the JET2 and I met some problems.
>
> I created an EMFT JET transformation project (the id is
> "my.jet.transformation") without any change and it worked perfectly via
> the run JET Transformation dialog.
>
> Then I created a test plug-in to execute the transformation. The running
> result is very weird for it threw a "java.lang.NoClassDefFoundError:
> org/eclipse/jet/JET2Platform" exception in JET2 0.7.1 while an error
> message of "Variable "org.eclipse.jet.resource.project.name" is not
> defined." in JET2 0.8.0 (during debuging).
>
> My test code in the test plugin is quite simple:
> ..
> IProgressMonitor monitor = new NullProgressMonitor();
> String TRANS = "my.jet.transformation";
> StringBuffer sb = readXML();
> IStatus st = JET2Platform.runTransformOnString(TRANS,
> sb.toString().trim(), monitor);
> ...
>
> What shall I do then?
>
> BTW, Is there any sample code or tutorial available for the freshman? I
> found JET Tutorial Part 1 and 2 but it seems that they are introduction
> for JET1.
>
Re: How to run a jet transformation in the plug-ins? [message #26352 is a reply to message #25945] Thu, 12 July 2007 14:08 Go to previous message
hamlin is currently offline hamlinFriend
Messages: 8
Registered: July 2009
Junior Member
Hi Paul,
Thanks so much for your patient answer which bring me to the interesting
JET2 world. I can run through the code now.

Chaohong
Previous Topic:Invoke JET2 Transformation from Java
Next Topic:Passing XPath result to custom tag
Goto Forum:
  


Current Time: Sun Nov 23 04:51:47 GMT 2014

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

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