Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » JET2 access to ecore references... again
JET2 access to ecore references... again [message #19505] Mon, 04 June 2007 12:49 Go to next message
Joaquin  Cañadas is currently offline Joaquin CañadasFriend
Messages: 25
Registered: July 2009
Junior Member
Hello,
I am trying to access to ecore references but I can not.

In a previous thread (13/03/2007, Vladimir Sosnin, Paul Elder) appears
an example which seems very easy to test, so I tried it. First, I
created a new EMFT Jet Transformation Project, copying in "sample.xml"
the instance model that they used, and in "dump.jet" the jet code as
they wrote (without the <c:log> tags) . After that, I created a
"simple.ecore" file with the example model as appears later, and set the
plugin.xml modelschema field as "simple.ecore". Then, I executed the Jet
project, but the result was:

A quick navigation of your model
Vars:
name = test1
name = test2
Classes:
class

So references are not correctly managed!!!!

Is there some missing??? Is there any configuration step necessary to
say that the instance model is an EMF based XMI model?

Thank you in advance.
Joaquin


sample.xml
------------------------------------------------------------ -
<?xml version="1.0" encoding="ASCII"?>
<smpl:Container xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:smpl="http://simple" xsi:schemaLocation="http://simple.ecore">
<vars name="test1"/>
<vars name="test2"/>
<class reference="//@vars.0 //@vars.1"/>
</smpl:Container>

dump.jet
------------------------------------------------------------ --
A quick navigation of your model
<c:iterate select="/Container" var="container">
Vars:
<c:iterate select="$container/vars" var="vars">
name = <c:get select="$vars/@name"/>
</c:iterate>
Classes:
<c:iterate select="$container/class" var="class">
class
<c:iterate select="$class/reference" var="reference">
reference to var named = <c:get select="$reference/@name"/>
</c:iterate>
</c:iterate>
</c:iterate>

simple.ecore
------------------------------------------------------------ ---
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="simple"
nsURI="http://simple" nsPrefix="smpl">
<eClassifiers xsi:type="ecore:EClass" name="SomeClass">
<eStructuralFeatures xsi:type="ecore:EReference" name="reference"
upperBound="-1"
eType="#//SomeVar"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="SomeVar">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
lowerBound="1" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Container">
<eStructuralFeatures xsi:type="ecore:EReference" name="vars"
upperBound="-1" eType="#//SomeVar"
containment="true"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="class"
eType="#//SomeClass"
containment="true"/>
</eClassifiers>
</ecore:EPackage>

plugin.xml
------------------------------------------------------------ ----------
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
<extension
id=""
name=""
point="org.eclipse.jet.transform">
<transform
modelSchema="simple.ecore"
startTemplate="templates/main.jet"

templateLoaderClass="org.eclipse.jet.compiled._jet_transformation ">
<description></description>
<tagLibraries>
<importLibrary id="org.eclipse.jet.controlTags"
usePrefix="c" autoImport="true"/>
<importLibrary id="org.eclipse.jet.javaTags"
usePrefix="java" autoImport="true"/>
<importLibrary id="org.eclipse.jet.formatTags"
usePrefix="f" autoImport="true"/>
<importLibrary id="org.eclipse.jet.workspaceTags"
usePrefix="ws" autoImport="false"/>
</tagLibraries>
</transform>
</extension>
</plugin>
Re: JET2 access to ecore references... again [message #19596 is a reply to message #19505] Mon, 04 June 2007 14:04 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Joaqu
Re: JET2 access to ecore references... again [message #19759 is a reply to message #19596] Mon, 04 June 2007 19:56 Go to previous messageGo to next message
Joaquin  Cañadas is currently offline Joaquin CañadasFriend
Messages: 25
Registered: July 2009
Junior Member
Paul,
thank you for your detailed answer. The creation of a EMF project and
the execution in a runtime workbench give me an idea: JET need to know
which is the .ecore metamodel. So I found another simple solution:
- right click on "simple.ecore"
- "Register Ecore Metamodel"

That's all !! Now, it works!!!
An important note: the option "Register (Ecore) Metamodel is available
in my Eclipse installation because I installed the ATL/AM3 plugin for
model-to-model transformations.

Regards
Joaquin


Paul Elder escribió:
> Joaquín:
>
> I was able to get your example to work. Here is what I did:
>
> 1) Took your simple.ecore file, and created an new EMF Project that
> referenced the file.
> 2) Once the new EMF project wizard completed, I opened
> models/simple.genmodel, right clicked, and choose Generate Model Code.
> 3) I then lauched a runtime workbench which included the plug-in created in
> steps 1 &2.
> 4) In the runtime workbench, I created a new JET project, and a sample.xml
> using your content.
> 5) When I ran the JET transformation on sample.xml, I got the following
> message:
>
> Error: Feature 'version' not found.
> (platform:/resource/read.simple.ecore/sample.xml, 4, 69)
>
> This is a manifestation of JET (with the help of EMF, but I'll take
> responsibility) failing to find an appropriate loader for the document. I
> will take a look at how JET can do this better, and have submitted bug
> 190809 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=190809) to track.
>
> At this point, I tried two alternatives: a) help JET find the correct loader
> for the documents' content; b) switch the file extension to correspond to
> the extension expected by EMF
>
> 6a) To give the right hints to JET, I had to tell it to do two things: i)
> load the document via EMF; ii) load the document as if it hand a '.simple'
> extension. To do both of these, I modified plugin.xml for the JET
> transformations. I added the modelExtension and modelLoader attributes to
> the (transform) element. You can do this from the Plug-in Manifest Editor's
> Extensions tab by expanding org.eclipse.jet.transform, and clicking on
> (transform), and then viewing and modifying the properties in the right-hand
> pane.
>
> 6b) EMF knows how to load the model if it has a '.simple' extension. But you
> still need to specify the org.eclipse.jet.emf modelLoader attribute in
> plugin.xml
>
> Here is the plug-in.xml that I used:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?eclipse version="3.0"?>
> <plugin>
> <extension
> id=""
> name=""
> point="org.eclipse.jet.transform">
> <transform
> modelExtension="simple"
> modelLoader="org.eclipse.jet.emf"
> startTemplate="templates/main.jet"
> templateLoaderClass="org.eclipse.jet.compiled._jet_transformation ">
> <description></description>
> <tagLibraries>
> <importLibrary id="org.eclipse.jet.controlTags" usePrefix="c"
> autoImport="true"/>
> <importLibrary id="org.eclipse.jet.javaTags" usePrefix="java"
> autoImport="true"/>
> <importLibrary id="org.eclipse.jet.formatTags" usePrefix="f"
> autoImport="true"/>
> <importLibrary id="org.eclipse.jet.workspaceTags" usePrefix="ws"
> autoImport="false"/>
> </tagLibraries>
> </transform>
> </extension>
> </plugin>
>
> Paul
>
>
Re: JET2 access to ecore references... again [message #20071 is a reply to message #19759] Tue, 05 June 2007 12:47 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Joaqu
Previous Topic:JET2 access to ecore references
Next Topic:new to JET2
Goto Forum:
  


Current Time: Wed Apr 24 21:19:10 GMT 2024

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

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

Back to the top