Home » Modeling » M2T (model-to-text transformation) » jets transformation
jets transformation [message #11849] |
Sun, 15 April 2007 11:25 |
Eclipse User |
|
|
|
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> </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> </DIV>
<DIV>I have my project EMFT ('mytrans') working correctly. </DIV>
<DIV> </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> </DIV>
<DIV>It's possible? Always I receive NullPointerException for =
runTransform=20
and runTransformXXX.</DIV>
<DIV> </DIV>
<DIV>I have tried these options</DIV>
<DIV> </DIV>
<DIV>*************************************************<BR>private void=20
transform()<BR> {<BR> IProgressMonitor monitor =3D new=20
NullProgressMonitor();<BR> String strXMLInput =3D=20
"sample.xml";<BR> String TRANS =3D=20
"org.eclipse.jet.transforms.mytrans";<BR> IJETBundleDescriptor=
=20
descriptor=3DJET2Platform.getJETBundleManager().getDescripto r( "mytrans");=
<BR> String=20
loaderId =3D descriptor.getModelLoaderId();</DIV>
<DIV> </DIV>
<DIV> (1) /*<BR> HashMap vMap =3D new=20
HashMap();<BR> vMap.put("projectName",=20
TRANS);<BR> vMap.put("fileName",=20
strXMLInput);<BR> JET2Context context =3D new=20
JET2Context(this.getClass());<BR> context.setVariables(vMap); <=
BR> IStatus=20
status =3D JET2Platform.runTransform( TRANS,=20
context,monitor);<BR> */<BR> <BR> (2)/*<BR> &nb=
sp;Map<String,=20
String> variables =3D new HashMap<String,=20
String>();<BR> variables.put("org.eclipse.jet.resource.proj=
ect.name","/"+TRANS);<BR> JET2Platform.runTransformOnString(TR=
ANS,=20
strXMLInput, "xml", variables,=20
monitor);<BR> */ <BR> (3)/* Map<String, =
String>=20
variables =3D new HashMap<String,=20
String>();<BR> variables.put("org.eclipse.jet.resource.proj=
ect.name","/"+TRANS);<BR> JET2Platform.runTransformOnString(lo=
aderId,=20
strXMLInput, "xml", variables,=20
monitor);<BR> */ <BR> (4)/* =20
<BR> StringBuffer xml =3D=20
readFile("c:\\sample.xml");<BR> System.out.println(xml.toStrin=
g());<BR> JET2Platform.runTransformOnString(TRANS, =20
xml.toString(), monitor);<BR> */<BR> =20
<BR> (5)/* StringBuffer xml =3D=20
readFile("c:\\sample.xml");<BR> System.out.println(xml.toStrin=
g());<BR> JET2Platform.runTransformOnString(loader Id,=20
xml.toString(),=20
monitor);<BR> */<BR> <BR> (6) //JET2Platf=
orm.runTransformOnResource("mytrans",=20
,=20
monitor)<BR> <BR> (7) //JET2Platform.runTransformOnS=
tring(TRANS,=20
strXMLInput,=20
monitor);<BR> <BR> (8) /*org.eclipse.emf.ecore.resou=
rce.Resource=20
myEMFModel =3D <BR> (Resource) =20
this.getClass().getResourceAsStream(strXMLInput);<BR> &n=
bsp;=20
JET2Platform.runTransformOnObject(TRANS, myEMFModel,=20
monitor);<BR> */<BR> <BR> (9) /*<BR> =
; org.eclipse.core.resources.IResource=20
myWorkspaceFile =3D <BR> (IResource)=20
this.getClass().getResourceAsStream(strXMLInput);<BR> &n=
bsp;=20
JET2Platform.runTransformOnResource (TRANS, myWorkspaceFile,=20
monitor);<BR> */ <BR> } <BR>*************************=
************************</DIV>
<DIV> </DIV>
<DIV>thx</DIV>
<P> </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 |
Paul Elder 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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
>
>
>
|
|
| |
Goto Forum:
Current Time: Sat Nov 09 04:11:34 GMT 2024
Powered by FUDForum. Page generated in 0.02822 seconds
|