Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » jets transformation
jets transformation [message #11849] Sun, 15 April 2007 11:25 Go to next message
Eclipse UserFriend
Originally posted by: alberto.gallen.gmail.com

This is a multi-part message in MIME format.

------=_NextPart_000_0046_01C77F61.7895FFC0
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_0047_01C77F61.789849B0"


------=_NextPart_001_0047_01C77F61.789849B0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

BlankHello :=20

I have followed the tutorial:
http://www-128.ibm.com/developerworks/opensource/library/os- ecl-jet/

I have my project EMFT ('mytrans') working correctly.=20

But i wanted to execute the transformation from a project java with my =
xml file. (inside eclipse but not a plugin project).=20

It's possible? Always I receive NullPointerException for runTransform =
and runTransformXXX.

I have tried these options

*************************************************
private void transform()
{
IProgressMonitor monitor =3D new NullProgressMonitor();
String strXMLInput =3D "sample.xml";
String TRANS =3D "org.eclipse.jet.transforms.mytrans";
IJETBundleDescriptor =
descriptor=3DJET2Platform.getJETBundleManager().getDescripto r( "mytrans");=

String loaderId =3D descriptor.getModelLoaderId();

(1) /*
HashMap vMap =3D new HashMap();
vMap.put("projectName", TRANS);
vMap.put("fileName", strXMLInput);
JET2Context context =3D new JET2Context(this.getClass());
context.setVariables(vMap);
IStatus status =3D JET2Platform.runTransform( TRANS, context,monitor);
*/
=20
(2)/*
Map<String, String> variables =3D new HashMap<String, String>();
variables.put("org.eclipse.jet.resource.project.name","/"+TRANS);
JET2Platform.runTransformOnString(TRANS, strXMLInput, "xml", =
variables, monitor);
*/=20
(3)/* Map<String, String> variables =3D new HashMap<String, String>();
variables.put("org.eclipse.jet.resource.project.name","/"+TRANS);
JET2Platform.runTransformOnString(loaderId, strXMLInput, "xml", =
variables, monitor);
*/=20
(4)/* =20
StringBuffer xml =3D readFile("c:\\sample.xml");
System.out.println(xml.toString());
JET2Platform.runTransformOnString(TRANS, xml.toString(), monitor);
*/
=20
(5)/* StringBuffer xml =3D readFile("c:\\sample.xml");
System.out.println(xml.toString());
JET2Platform.runTransformOnString(loaderId, xml.toString(), monitor);
*/
=20
(6) //JET2Platform.runTransformOnResource("mytrans", , monitor)
=20
(7) //JET2Platform.runTransformOnString(TRANS, strXMLInput, monitor);
=20
(8) /*org.eclipse.emf.ecore.resource.Resource myEMFModel =3D=20
(Resource) this.getClass().getResourceAsStream(strXMLInput);
JET2Platform.runTransformOnObject(TRANS, myEMFModel, monitor);
*/
=20
(9) /*
org.eclipse.core.resources.IResource myWorkspaceFile =3D=20
(IResource) this.getClass().getResourceAsStream(strXMLInput);
JET2Platform.runTransformOnResource (TRANS, myWorkspaceFile, =
monitor);
*/=20
}
*************************************************

thx


------=_NextPart_001_0047_01C77F61.789849B0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE id=3DridTitle>Blank</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252"><BASE=20
href=3D"file://C:\Program Files\Common Files\Microsoft =
Shared\Stationery\">
<STYLE>BODY {
MARGIN-TOP: 25px; FONT-SIZE: 10pt; MARGIN-LEFT: 25px; COLOR: #000000; =
FONT-FAMILY: Arial, Helvetica
}
P.msoNormal {
MARGIN-TOP: 0px; FONT-SIZE: 10pt; MARGIN-LEFT: 0px; COLOR: #ffffcc; =
FONT-FAMILY: Helvetica, "Times New Roman"
}
LI.msoNormal {
MARGIN-TOP: 0px; FONT-SIZE: 10pt; MARGIN-LEFT: 0px; COLOR: #ffffcc; =
FONT-FAMILY: Helvetica, "Times New Roman"
}
</STYLE>

<META content=3D"MSHTML 6.00.2900.2912" name=3DGENERATOR></HEAD>
<BODY id=3DridBody bgColor=3D#ffffff=20
background=3Dcid:004101c77f50$b4fed7e0$0201010a@GELATINAX>
<DIV>Hello : </DIV>
<DIV>&nbsp;</DIV>
<DIV>I have followed the tutorial:<BR><A=20
href=3D" http://www-128.ibm.com/developerworks/opensource/library/os- ecl-j=
et/"> http://www-128.ibm.com/developerworks/opensource/library/os- ecl-jet/=
</A></DIV>
<DIV>&nbsp;</DIV>
<DIV>I have my project EMFT ('mytrans') working correctly. </DIV>
<DIV>&nbsp;</DIV>
<DIV>But i wanted to execute the transformation from a project java with =
my xml=20
file. (inside eclipse but not a plugin project). </DIV>
<DIV>&nbsp;</DIV>
<DIV>It's possible? Always I receive NullPointerException&nbsp; for =
runTransform=20
and runTransformXXX.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I have tried these options</DIV>
<DIV>&nbsp;</DIV>
<DIV>*************************************************<BR>private void=20
transform()<BR>&nbsp;{<BR>&nbsp;&nbsp;IProgressMonitor monitor =3D new=20
NullProgressMonitor();<BR>&nbsp;&nbsp;String strXMLInput =3D=20
"sample.xml";<BR>&nbsp;&nbsp;String TRANS =3D=20
"org.eclipse.jet.transforms.mytrans";<BR>&nbsp;&nbsp;IJETBundleDescriptor=
=20
descriptor=3DJET2Platform.getJETBundleManager().getDescripto r( "mytrans");=
<BR>&nbsp;&nbsp;String=20
loaderId =3D descriptor.getModelLoaderId();</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;(1)&nbsp;/*<BR>&nbsp;&nbsp; HashMap vMap =3D new=20
HashMap();<BR>&nbsp;&nbsp;vMap.put("projectName",=20
TRANS);<BR>&nbsp;&nbsp;vMap.put("fileName",=20
strXMLInput);<BR>&nbsp;&nbsp;JET2Context context =3D new=20
JET2Context(this.getClass());<BR>&nbsp;&nbsp;context.setVariables(vMap); <=
BR>&nbsp;&nbsp;IStatus=20
status =3D JET2Platform.runTransform(&nbsp;TRANS,=20
context,monitor);<BR>&nbsp;&nbsp;*/<BR>&nbsp; <BR>&nbsp;(2)/*<BR>&nbsp;&nb=
sp;Map&lt;String,=20
String&gt; variables =3D new HashMap&lt;String,=20
String&gt;();<BR>&nbsp;&nbsp;variables.put("org.eclipse.jet.resource.proj=
ect.name","/"+TRANS);<BR>&nbsp;&nbsp;JET2Platform.runTransformOnString(TR=
ANS,=20
strXMLInput, "xml", variables,=20
monitor);<BR>&nbsp;&nbsp;*/&nbsp;<BR>&nbsp;(3)/*&nbsp;Map&lt;String, =
String&gt;=20
variables =3D new HashMap&lt;String,=20
String&gt;();<BR>&nbsp;&nbsp;variables.put("org.eclipse.jet.resource.proj=
ect.name","/"+TRANS);<BR>&nbsp;&nbsp;JET2Platform.runTransformOnString(lo=
aderId,=20
strXMLInput, "xml", variables,=20
monitor);<BR>&nbsp;&nbsp;*/&nbsp;<BR>&nbsp;(4)/*&nbsp;=20
&nbsp;<BR>&nbsp;&nbsp;StringBuffer xml =3D=20
readFile("c:\\sample.xml");<BR>&nbsp;&nbsp;System.out.println(xml.toStrin=
g());<BR> &nbsp;&nbsp;JET2Platform.runTransformOnString(TRANS, =20
xml.toString(), monitor);<BR>&nbsp;&nbsp;*/<BR>&nbsp;&nbsp;&nbsp;=20
&nbsp;<BR>&nbsp;(5)/*&nbsp;StringBuffer xml =3D=20
readFile("c:\\sample.xml");<BR>&nbsp;&nbsp;System.out.println(xml.toStrin=
g());<BR> &nbsp;&nbsp;JET2Platform.runTransformOnString(loader Id,=20
xml.toString(),=20
monitor);<BR>&nbsp;&nbsp;*/<BR>&nbsp;&nbsp; <BR>&nbsp;(6)&nbsp;//JET2Platf=
orm.runTransformOnResource("mytrans",=20
,=20
monitor)<BR>&nbsp;&nbsp;<BR>&nbsp;(7)&nbsp;//JET2Platform.runTransformOnS=
tring(TRANS,=20
strXMLInput,=20
monitor);<BR>&nbsp;&nbsp;<BR>&nbsp;(8)&nbsp;/*org.eclipse.emf.ecore.resou=
rce.Resource=20
myEMFModel =3D <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Resource) =20
this.getClass().getResourceAsStream(strXMLInput);<BR>&nbsp;&nbsp;&nbsp;&n=
bsp;=20
JET2Platform.runTransformOnObject(TRANS, myEMFModel,=20
monitor);<BR>&nbsp;&nbsp;*/<BR>&nbsp;&nbsp; <BR>&nbsp;(9)&nbsp;/*<BR>&nbsp=
;&nbsp;org.eclipse.core.resources.IResource=20
myWorkspaceFile =3D <BR>&nbsp;&nbsp;&nbsp; (IResource)=20
this.getClass().getResourceAsStream(strXMLInput);<BR>&nbsp;&nbsp;&nbsp;&n=
bsp;=20
JET2Platform.runTransformOnResource (TRANS, myWorkspaceFile,=20
monitor);<BR>&nbsp;&nbsp;*/&nbsp;<BR>&nbsp;} <BR>*************************=
************************</DIV>
<DIV>&nbsp;</DIV>
<DIV>thx</DIV>
<P>&nbsp;</P></BODY></HTML>

------=_NextPart_001_0047_01C77F61.789849B0--

------=_NextPart_000_0046_01C77F61.7895FFC0
Content-Type: image/gif;
name="Blank Bkgrd.gif"
Content-Transfer-Encoding: base64
Content-ID: <004101c77f50$b4fed7e0$0201010a@GELATINAX>

R0lGODlhLQAtAID/AP////f39ywAAAAALQAtAEACcAxup8vtvxKQsFon6d02 898pGkgiYoCm6sq2
7iqWcmzOsmeXeA7uPJd5CYdD2g9oPF58ygqz+XhCG9JpJGmlYrPXGlfr/Yo/ VW45e7amp2tou/lW
xo/zX513z+Vt+1n/tiX2pxP4NUhy2FM4xtjIUQAAOw==

------=_NextPart_000_0046_01C77F61.7895FFC0--
Re: jets transformation [message #13059 is a reply to message #11849] Wed, 18 April 2007 13:51 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
BlankAlberto:

Short answer:

JET Transforms must be launched from an Eclipse plug-in.

More detailed answer:

JET transforms must run with-in Eclipse. Your non-Eclipse plug-in Java
project does not satisfy this requirement - when you launch the Java
program, it gets its own JRE, which does not include the essentail Eclipse
bits.

I am working on re-factoring JET so that some sort of Eclipse-free behaviour
is possible, but I cannot promise immediate results - there is still much
work to do. Some examples of the dependencies JET still has one Eclipse:

1) dynamic loading of JET projects is done through OSGi. This will not
change, but for a Java program without OSGi, it should be possible to at
least run a JET template by creating a JET2Context and JET2Writer and
instantiating the Java class created by the JET compiler and calling the
generate() method. I'm close on this, but it requires the removal of some
deprecated methods on JET2Writer.

2) Many JET tags (ws:file, ws:project, ...) have dependencies on the Eclipse
workspace. It should be possible to have versions of these that work just
with java.io.File, but this is not done yet.

3) Several JET tags make use of the org.eclipse.text plug-in and, in
particular the IDocument interface. JET 0.8.0 has started to refactor some
of this, but still it is not perfect.

Paul
Re: jets transformation [message #13088 is a reply to message #13059] Wed, 18 April 2007 20:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alberto.gallen.gmail.com

Paul
The explanation has been very good.

Thanks for your interest, and the time that you use in responding to us.
Congratulations by the work and thanks once again

Alberto

"Paul Elder" <pelder@ca.ibm.com> escribi
Re: jets transformation [message #13147 is a reply to message #13059] Thu, 19 April 2007 00:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: evaandoli.dodo.com.au

Paul,

Can JET run in a Eclipse - RCP environment (so thus outside of eclipse) ?

"Paul Elder" <pelder@ca.ibm.com> wrote in message
news:f057ou$j41$1@build.eclipse.org...
> BlankAlberto:
>
> Short answer:
>
> JET Transforms must be launched from an Eclipse plug-in.
>
> More detailed answer:
>
> JET transforms must run with-in Eclipse. Your non-Eclipse plug-in Java
> project does not satisfy this requirement - when you launch the Java
> program, it gets its own JRE, which does not include the essentail Eclipse
> bits.
>
> I am working on re-factoring JET so that some sort of Eclipse-free
> behaviour is possible, but I cannot promise immediate results - there is
> still much work to do. Some examples of the dependencies JET still has one
> Eclipse:
>
> 1) dynamic loading of JET projects is done through OSGi. This will not
> change, but for a Java program without OSGi, it should be possible to at
> least run a JET template by creating a JET2Context and JET2Writer and
> instantiating the Java class created by the JET compiler and calling the
> generate() method. I'm close on this, but it requires the removal of some
> deprecated methods on JET2Writer.
>
> 2) Many JET tags (ws:file, ws:project, ...) have dependencies on the
> Eclipse workspace. It should be possible to have versions of these that
> work just with java.io.File, but this is not done yet.
>
> 3) Several JET tags make use of the org.eclipse.text plug-in and, in
> particular the IDocument interface. JET 0.8.0 has started to refactor some
> of this, but still it is not perfect.
>
> Paul
>
>
>
Re: jets transformation [message #13176 is a reply to message #13147] Thu, 19 April 2007 13:46 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Stu:

Not yet. I'm working on it.

Paul
Previous Topic:XPath expression returned no result
Next Topic:Freshly Created JET2 Transformation Failure
Goto Forum:
  


Current Time: Thu Apr 25 22:49:55 GMT 2024

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

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

Back to the top