Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Transforming Xtext DSL to XMI(Trying to get DSL instance and transform it to XMI)
Transforming Xtext DSL to XMI [message #1735652] Tue, 21 June 2016 15:35 Go to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 50
Registered: March 2014
Member
Hi everyone,

I have two DSL (Mapping DSL and Trace DSL) where the later uses the other one.
At runtime I have a sample.mapping and a sample.trace. I created a plugin to generate the XMI from the .trace file using a code find here. The code is:

Injector injector = new TraceStandaloneSetup().createInjectorAndDoEMFRegistration();

XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
			
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
			
Resource xtextResource = resourceSet.getResource(URI.createURI("platform:/resource/DSLExample/sample.trace"), true);
			
EcoreUtil.resolveAll(xtextResource);
			
Resource xmiResource = resourceSet.createResource(URI.createURI("platform:/resource/DSLExample/application.xmi"));
			
FormalResult model = (FormalResult) xtextResource.getContents().get(0);

xmiResource.getContents().add(xtextResource.getContents().get(0));
try {
       xmiResource.save(null);
} catch (IOException e) {
	e.printStackTrace();
}


The error message is:
Quote:

!ENTRY org.eclipse.ui 4 0 2016-06-21 12:09:20.502
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBoundsException: index=0, size=0
at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:346)
at br.traceability.utils.popup.actions.DSLReader.transformXTextToXMI(DSLReader.java:62)
at br.traceability.utils.popup.actions.NewAction.run(NewAction.java:32)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:247)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
at org.eclipse.equinox.launcher.Main.main(Main.java:1488)


I want to generate the XMI to later use ATL to transform my PIM (both DSL) to a PSM. But I'm getting some punches in my face from the XMI =)

Could anyone help me?
Re: Transforming Xtext DSL to XMI [message #1735653 is a reply to message #1735652] Tue, 21 June 2016 15:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
Please NEVERcall standalone setup from eclipse

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Transforming Xtext DSL to XMI [message #1735654 is a reply to message #1735653] Tue, 21 June 2016 16:15 Go to previous messageGo to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 50
Registered: March 2014
Member
Sorry but what?? I'm lost here...

I got the code from here: https://www.eclipse.org/forums/index.php?t=msg&th=292631&goto=801725&#msg_801725

So how is the right way?
Re: Transforming Xtext DSL to XMI [message #1735656 is a reply to message #1735654] Tue, 21 June 2016 16:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html?m=1

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Transforming Xtext DSL to XMI [message #1735665 is a reply to message #1735656] Tue, 21 June 2016 18:20 Go to previous messageGo to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 50
Registered: March 2014
Member
Thanks!!

Good to know this... but I still didn't manage to make my code run... some help, please?
Re: Transforming Xtext DSL to XMI [message #1735666 is a reply to message #1735665] Tue, 21 June 2016 18:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
Please provide the code in a way I can simply run it

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Transforming Xtext DSL to XMI [message #1735668 is a reply to message #1735666] Tue, 21 June 2016 18:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
Btw why not feeding atl directly with the xtext model

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Transforming Xtext DSL to XMI [message #1735672 is a reply to message #1735666] Tue, 21 June 2016 20:11 Go to previous messageGo to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 50
Registered: March 2014
Member
Hi Christian,

here is the code: https://github.com/vinpereira/XtextToXMI

And the answer to the question "Btw why not feeding atl directly with the xtext model" is: because I don't know how.

As far I know (it's a very low knowledge), I need to do this steps:
(1) define my DSL (or DSLs in this case)
(2) use the Trace.ecore (with the reference to Mapping.ecore) as source model to a ATL transformation
(3) use a target model (another Ecore file)
(4) have one XMI file for the input (based on the Ecore input)
(5) run the .atl file with the transformation rules
(6) have the XMI file for the target model

The problem for me is the (4). I need the XMI file for the Trace. And I need that this XMI have the references for the Mapping.

Of course, if there is a better way, I want to learn. =)
Re: Transforming Xtext DSL to XMI [message #1735676 is a reply to message #1735672] Tue, 21 June 2016 21:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
Hi,

i just have it a try and atl seems to work file with xtext models as input
(i started a new runtime workspace, created dsl files and atl stuff there)
(i am no atl guru and have no idea what i am doing)

demo.atl
-- @nsURI MM1=http://www.xtext.org/example/dsl/Trace
-- @nsURI MM=http://www.xtext.org/example/mydsl/MyDsl
-- @nsURI MM2=http://www.xtext.org/example/mapping/Mapping


module demo;
create OUT: MM from IN1: MM1, IN: MM2;

rule name {
	from
		fr: MM1!FormalResult
	to
		g: MM!Greeting (
			name <- fr.name
		),
		g2: MM!Greeting (
			name <- 'x'+fr.formalElements.at(1).formalElement.name
		),
		output_name: MM!Model (
			greetings <- g,
			greetings <- g2
		)
}

rule FE2G {
	from
		fe: MM1!FormalElement
	to
		g: MM!Greeting (
		)
}



demo.asm
<?xml version = '1.0' encoding = 'ISO-8859-1' ?>
<asm version="1.0" name="0">
	<cp>
		<constant value="demo"/>
		<constant value="links"/>
		<constant value="NTransientLinkSet;"/>
		<constant value="col"/>
		<constant value="J"/>
		<constant value="main"/>
		<constant value="A"/>
		<constant value="OclParametrizedType"/>
		<constant value="#native"/>
		<constant value="Collection"/>
		<constant value="J.setName(S):V"/>
		<constant value="OclSimpleType"/>
		<constant value="OclAny"/>
		<constant value="J.setElementType(J):V"/>
		<constant value="TransientLinkSet"/>
		<constant value="A.__matcher__():V"/>
		<constant value="A.__exec__():V"/>
		<constant value="self"/>
		<constant value="__resolve__"/>
		<constant value="1"/>
		<constant value="J.oclIsKindOf(J):B"/>
		<constant value="18"/>
		<constant value="NTransientLinkSet;.getLinkBySourceElement(S):QNTransientLink;"/>
		<constant value="J.oclIsUndefined():B"/>
		<constant value="15"/>
		<constant value="NTransientLink;.getTargetFromSource(J):J"/>
		<constant value="17"/>
		<constant value="30"/>
		<constant value="Sequence"/>
		<constant value="2"/>
		<constant value="A.__resolve__(J):J"/>
		<constant value="QJ.including(J):QJ"/>
		<constant value="QJ.flatten():QJ"/>
		<constant value="e"/>
		<constant value="value"/>
		<constant value="resolveTemp"/>
		<constant value="S"/>
		<constant value="NTransientLink;.getNamedTargetFromSource(JS):J"/>
		<constant value="name"/>
		<constant value="__matcher__"/>
		<constant value="A.__matchname():V"/>
		<constant value="A.__matchFE2G():V"/>
		<constant value="__exec__"/>
		<constant value="NTransientLinkSet;.getLinksByRule(S):QNTransientLink;"/>
		<constant value="A.__applyname(NTransientLink;):V"/>
		<constant value="FE2G"/>
		<constant value="A.__applyFE2G(NTransientLink;):V"/>
		<constant value="__matchname"/>
		<constant value="FormalResult"/>
		<constant value="MM1"/>
		<constant value="IN1"/>
		<constant value="MMOF!Classifier;.allInstancesFrom(S):QJ"/>
		<constant value="TransientLink"/>
		<constant value="NTransientLink;.setRule(MATL!Rule;):V"/>
		<constant value="fr"/>
		<constant value="NTransientLink;.addSourceElement(SJ):V"/>
		<constant value="g"/>
		<constant value="Greeting"/>
		<constant value="MM"/>
		<constant value="NTransientLink;.addTargetElement(SJ):V"/>
		<constant value="g2"/>
		<constant value="output_name"/>
		<constant value="Model"/>
		<constant value="NTransientLinkSet;.addLink2(NTransientLink;B):V"/>
		<constant value="13:3-15:4"/>
		<constant value="16:3-18:4"/>
		<constant value="19:3-22:4"/>
		<constant value="__applyname"/>
		<constant value="NTransientLink;"/>
		<constant value="NTransientLink;.getSourceElement(S):J"/>
		<constant value="NTransientLink;.getTargetElement(S):J"/>
		<constant value="3"/>
		<constant value="4"/>
		<constant value="5"/>
		<constant value="x"/>
		<constant value="formalElements"/>
		<constant value="J.at(J):J"/>
		<constant value="formalElement"/>
		<constant value="J.+(J):J"/>
		<constant value="greetings"/>
		<constant value="14:12-14:14"/>
		<constant value="14:12-14:19"/>
		<constant value="14:4-14:19"/>
		<constant value="17:12-17:15"/>
		<constant value="17:16-17:18"/>
		<constant value="17:16-17:33"/>
		<constant value="17:37-17:38"/>
		<constant value="17:16-17:39"/>
		<constant value="17:16-17:53"/>
		<constant value="17:16-17:58"/>
		<constant value="17:12-17:58"/>
		<constant value="17:4-17:58"/>
		<constant value="20:17-20:18"/>
		<constant value="20:4-20:18"/>
		<constant value="21:17-21:19"/>
		<constant value="21:4-21:19"/>
		<constant value="link"/>
		<constant value="__matchFE2G"/>
		<constant value="FormalElement"/>
		<constant value="fe"/>
		<constant value="29:3-30:4"/>
		<constant value="__applyFE2G"/>
	</cp>
	<field name="1" type="2"/>
	<field name="3" type="4"/>
	<operation name="5">
		<context type="6"/>
		<parameters>
		</parameters>
		<code>
			<getasm/>
			<push arg="7"/>
			<push arg="8"/>
			<new/>
			<dup/>
			<push arg="9"/>
			<pcall arg="10"/>
			<dup/>
			<push arg="11"/>
			<push arg="8"/>
			<new/>
			<dup/>
			<push arg="12"/>
			<pcall arg="10"/>
			<pcall arg="13"/>
			<set arg="3"/>
			<getasm/>
			<push arg="14"/>
			<push arg="8"/>
			<new/>
			<set arg="1"/>
			<getasm/>
			<pcall arg="15"/>
			<getasm/>
			<pcall arg="16"/>
		</code>
		<linenumbertable>
		</linenumbertable>
		<localvariabletable>
			<lve slot="0" name="17" begin="0" end="24"/>
		</localvariabletable>
	</operation>
	<operation name="18">
		<context type="6"/>
		<parameters>
			<parameter name="19" type="4"/>
		</parameters>
		<code>
			<load arg="19"/>
			<getasm/>
			<get arg="3"/>
			<call arg="20"/>
			<if arg="21"/>
			<getasm/>
			<get arg="1"/>
			<load arg="19"/>
			<call arg="22"/>
			<dup/>
			<call arg="23"/>
			<if arg="24"/>
			<load arg="19"/>
			<call arg="25"/>
			<goto arg="26"/>
			<pop/>
			<load arg="19"/>
			<goto arg="27"/>
			<push arg="28"/>
			<push arg="8"/>
			<new/>
			<load arg="19"/>
			<iterate/>
			<store arg="29"/>
			<getasm/>
			<load arg="29"/>
			<call arg="30"/>
			<call arg="31"/>
			<enditerate/>
			<call arg="32"/>
		</code>
		<linenumbertable>
		</linenumbertable>
		<localvariabletable>
			<lve slot="2" name="33" begin="23" end="27"/>
			<lve slot="0" name="17" begin="0" end="29"/>
			<lve slot="1" name="34" begin="0" end="29"/>
		</localvariabletable>
	</operation>
	<operation name="35">
		<context type="6"/>
		<parameters>
			<parameter name="19" type="4"/>
			<parameter name="29" type="36"/>
		</parameters>
		<code>
			<getasm/>
			<get arg="1"/>
			<load arg="19"/>
			<call arg="22"/>
			<load arg="19"/>
			<load arg="29"/>
			<call arg="37"/>
		</code>
		<linenumbertable>
		</linenumbertable>
		<localvariabletable>
			<lve slot="0" name="17" begin="0" end="6"/>
			<lve slot="1" name="34" begin="0" end="6"/>
			<lve slot="2" name="38" begin="0" end="6"/>
		</localvariabletable>
	</operation>
	<operation name="39">
		<context type="6"/>
		<parameters>
		</parameters>
		<code>
			<getasm/>
			<pcall arg="40"/>
			<getasm/>
			<pcall arg="41"/>
		</code>
		<linenumbertable>
		</linenumbertable>
		<localvariabletable>
			<lve slot="0" name="17" begin="0" end="3"/>
		</localvariabletable>
	</operation>
	<operation name="42">
		<context type="6"/>
		<parameters>
		</parameters>
		<code>
			<getasm/>
			<get arg="1"/>
			<push arg="38"/>
			<call arg="43"/>
			<iterate/>
			<store arg="19"/>
			<getasm/>
			<load arg="19"/>
			<pcall arg="44"/>
			<enditerate/>
			<getasm/>
			<get arg="1"/>
			<push arg="45"/>
			<call arg="43"/>
			<iterate/>
			<store arg="19"/>
			<getasm/>
			<load arg="19"/>
			<pcall arg="46"/>
			<enditerate/>
		</code>
		<linenumbertable>
		</linenumbertable>
		<localvariabletable>
			<lve slot="1" name="33" begin="5" end="8"/>
			<lve slot="1" name="33" begin="15" end="18"/>
			<lve slot="0" name="17" begin="0" end="19"/>
		</localvariabletable>
	</operation>
	<operation name="47">
		<context type="6"/>
		<parameters>
		</parameters>
		<code>
			<push arg="48"/>
			<push arg="49"/>
			<findme/>
			<push arg="50"/>
			<call arg="51"/>
			<iterate/>
			<store arg="19"/>
			<getasm/>
			<get arg="1"/>
			<push arg="52"/>
			<push arg="8"/>
			<new/>
			<dup/>
			<push arg="38"/>
			<pcall arg="53"/>
			<dup/>
			<push arg="54"/>
			<load arg="19"/>
			<pcall arg="55"/>
			<dup/>
			<push arg="56"/>
			<push arg="57"/>
			<push arg="58"/>
			<new/>
			<pcall arg="59"/>
			<dup/>
			<push arg="60"/>
			<push arg="57"/>
			<push arg="58"/>
			<new/>
			<pcall arg="59"/>
			<dup/>
			<push arg="61"/>
			<push arg="62"/>
			<push arg="58"/>
			<new/>
			<pcall arg="59"/>
			<pusht/>
			<pcall arg="63"/>
			<enditerate/>
		</code>
		<linenumbertable>
			<lne id="64" begin="19" end="24"/>
			<lne id="65" begin="25" end="30"/>
			<lne id="66" begin="31" end="36"/>
		</linenumbertable>
		<localvariabletable>
			<lve slot="1" name="54" begin="6" end="38"/>
			<lve slot="0" name="17" begin="0" end="39"/>
		</localvariabletable>
	</operation>
	<operation name="67">
		<context type="6"/>
		<parameters>
			<parameter name="19" type="68"/>
		</parameters>
		<code>
			<load arg="19"/>
			<push arg="54"/>
			<call arg="69"/>
			<store arg="29"/>
			<load arg="19"/>
			<push arg="56"/>
			<call arg="70"/>
			<store arg="71"/>
			<load arg="19"/>
			<push arg="60"/>
			<call arg="70"/>
			<store arg="72"/>
			<load arg="19"/>
			<push arg="61"/>
			<call arg="70"/>
			<store arg="73"/>
			<load arg="71"/>
			<dup/>
			<getasm/>
			<load arg="29"/>
			<get arg="38"/>
			<call arg="30"/>
			<set arg="38"/>
			<pop/>
			<load arg="72"/>
			<dup/>
			<getasm/>
			<push arg="74"/>
			<load arg="29"/>
			<get arg="75"/>
			<pushi arg="19"/>
			<call arg="76"/>
			<get arg="77"/>
			<get arg="38"/>
			<call arg="78"/>
			<call arg="30"/>
			<set arg="38"/>
			<pop/>
			<load arg="73"/>
			<dup/>
			<getasm/>
			<load arg="71"/>
			<call arg="30"/>
			<set arg="79"/>
			<dup/>
			<getasm/>
			<load arg="72"/>
			<call arg="30"/>
			<set arg="79"/>
			<pop/>
		</code>
		<linenumbertable>
			<lne id="80" begin="19" end="19"/>
			<lne id="81" begin="19" end="20"/>
			<lne id="82" begin="17" end="22"/>
			<lne id="64" begin="16" end="23"/>
			<lne id="83" begin="27" end="27"/>
			<lne id="84" begin="28" end="28"/>
			<lne id="85" begin="28" end="29"/>
			<lne id="86" begin="30" end="30"/>
			<lne id="87" begin="28" end="31"/>
			<lne id="88" begin="28" end="32"/>
			<lne id="89" begin="28" end="33"/>
			<lne id="90" begin="27" end="34"/>
			<lne id="91" begin="25" end="36"/>
			<lne id="65" begin="24" end="37"/>
			<lne id="92" begin="41" end="41"/>
			<lne id="93" begin="39" end="43"/>
			<lne id="94" begin="46" end="46"/>
			<lne id="95" begin="44" end="48"/>
			<lne id="66" begin="38" end="49"/>
		</linenumbertable>
		<localvariabletable>
			<lve slot="3" name="56" begin="7" end="49"/>
			<lve slot="4" name="60" begin="11" end="49"/>
			<lve slot="5" name="61" begin="15" end="49"/>
			<lve slot="2" name="54" begin="3" end="49"/>
			<lve slot="0" name="17" begin="0" end="49"/>
			<lve slot="1" name="96" begin="0" end="49"/>
		</localvariabletable>
	</operation>
	<operation name="97">
		<context type="6"/>
		<parameters>
		</parameters>
		<code>
			<push arg="98"/>
			<push arg="49"/>
			<findme/>
			<push arg="50"/>
			<call arg="51"/>
			<iterate/>
			<store arg="19"/>
			<getasm/>
			<get arg="1"/>
			<push arg="52"/>
			<push arg="8"/>
			<new/>
			<dup/>
			<push arg="45"/>
			<pcall arg="53"/>
			<dup/>
			<push arg="99"/>
			<load arg="19"/>
			<pcall arg="55"/>
			<dup/>
			<push arg="56"/>
			<push arg="57"/>
			<push arg="58"/>
			<new/>
			<pcall arg="59"/>
			<pusht/>
			<pcall arg="63"/>
			<enditerate/>
		</code>
		<linenumbertable>
			<lne id="100" begin="19" end="24"/>
		</linenumbertable>
		<localvariabletable>
			<lve slot="1" name="99" begin="6" end="26"/>
			<lve slot="0" name="17" begin="0" end="27"/>
		</localvariabletable>
	</operation>
	<operation name="101">
		<context type="6"/>
		<parameters>
			<parameter name="19" type="68"/>
		</parameters>
		<code>
			<load arg="19"/>
			<push arg="99"/>
			<call arg="69"/>
			<store arg="29"/>
			<load arg="19"/>
			<push arg="56"/>
			<call arg="70"/>
			<store arg="71"/>
			<load arg="71"/>
			<pop/>
		</code>
		<linenumbertable>
			<lne id="100" begin="8" end="9"/>
		</linenumbertable>
		<localvariabletable>
			<lve slot="3" name="56" begin="7" end="9"/>
			<lve slot="2" name="99" begin="3" end="9"/>
			<lve slot="0" name="17" begin="0" end="9"/>
			<lve slot="1" name="96" begin="0" end="9"/>
		</localvariabletable>
	</operation>
</asm>



xxx.launch

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2m.atl.adt.launching.atlTransformation">
<stringAttribute key="ATL File Name" value="/demo.atl/demo.atl"/>
<stringAttribute key="ATL VM" value="EMF-specific VM"/>
<stringAttribute key="ATL_COMPILER" value="atl2006"/>
<booleanAttribute key="IS_REFINING" value="false"/>
<mapAttribute key="Input">
<mapEntry key="IN" value="MM2"/>
<mapEntry key="IN1" value="MM1"/>
</mapAttribute>
<mapAttribute key="Libs"/>
<mapAttribute key="Model Handler">
<mapEntry key="MM" value="EMF"/>
<mapEntry key="MM1" value="EMF"/>
<mapEntry key="MM2" value="EMF"/>
</mapAttribute>
<mapAttribute key="ModelType">
<mapEntry key="IN" value="MODELINPUT"/>
<mapEntry key="IN1" value="MODELINPUT"/>
<mapEntry key="MM" value="METAMODELOUTPUT"/>
<mapEntry key="MM1" value="METAMODELINPUT"/>
<mapEntry key="MM2" value="METAMODELINPUT"/>
<mapEntry key="OUT" value="MODELOUTPUT"/>
</mapAttribute>
<mapAttribute key="Options">
<mapEntry key="OPTION_CLEAR" value="false"/>
<mapEntry key="OPTION_CONTENT_TYPE" value="false"/>
<mapEntry key="OPTION_DERIVED" value="true"/>
<mapEntry key="allowInterModelReferences" value="false"/>
<mapEntry key="printExecutionTime" value="false"/>
<mapEntry key="step" value="false"/>
<mapEntry key="supportUML2Stereotypes" value="false"/>
</mapAttribute>
<listAttribute key="OrderedInput">
<listEntry value="IN1"/>
<listEntry value="IN"/>
</listAttribute>
<listAttribute key="OrderedOutput">
<listEntry value="OUT"/>
</listAttribute>
<mapAttribute key="Output">
<mapEntry key="OUT" value="MM"/>
</mapAttribute>
<mapAttribute key="Path">
<mapEntry key="IN" value="/demo.atl/b.mapping"/>
<mapEntry key="IN1" value="/demo.atl/a.trace"/>
<mapEntry key="MM" value="uri:http://www.xtext.org/example/mydsl/MyDsl"/>
<mapEntry key="MM1" value="uri:http://www.xtext.org/example/dsl/Trace"/>
<mapEntry key="MM2" value="uri:http://www.xtext.org/example/mapping/Mapping"/>
<mapEntry key="OUT" value="/demo.atl/result.mydsl"/>
</mapAttribute>
<listAttribute key="Superimpose"/>
<stringAttribute key="bad_container_name" value="/demo.atlx"/>
</launchConfiguration>



if you need xmi anyway? do you want to have a xmi for both inputs or only for one?
in your code you attempt to transform only one


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Transforming Xtext DSL to XMI [message #1735677 is a reply to message #1735676] Tue, 21 June 2016 21:17 Go to previous messageGo to next message
Vinicius Pereira is currently offline Vinicius PereiraFriend
Messages: 50
Registered: March 2014
Member
wow thanks Christian!!

I didn't try to use the ATL at runtime with "only" the .trace and .mapping files.
I believed that I need the XMI to works.

And I will transform only the .trace file. The .mapping file is a "control" generated automatically by another tool.


I will analyze what I did!!
Again, thank you!!
Re: Transforming Xtext DSL to XMI [message #1735678 is a reply to message #1735677] Tue, 21 June 2016 21:19 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
here some extremely dirty code for xmi

package org.xtext.example.plugin.popup.actions;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.xtext.resource.IResourceServiceProvider;
import org.eclipse.xtext.ui.resource.IResourceSetProvider;

import com.google.common.collect.Lists;

public class DSLReader {

	public static void transformXTextToXMI(String catalogueRefactoringDslFileToBeRead,
			String applicationDslFileToBeRead, Shell shell) {

		IResourceSetProvider rsp = IResourceServiceProvider.Registry.INSTANCE
				.getResourceServiceProvider(URI.createURI("dummy.trace")).get(IResourceSetProvider.class);

		ResourceSet resourceSet = rsp.get(ResourcesPlugin.getWorkspace().getRoot().getProject("DSLExample"));

		Resource xtextResource = resourceSet.getResource(URI.createURI("platform:/resource/DSLExample/sample.trace"),
				true);

		EcoreUtil.resolveAll(resourceSet);

		List<Resource> xmiResources = new ArrayList<>();
		for (Resource r : Lists.newArrayList(resourceSet.getResources())) {
			Resource xmiResource = resourceSet
					.createResource(URI.createURI("platform:/resource/DSLExample/"+r.getURI().trimFileExtension().lastSegment()+".xmi"));

			// FormalResult model = (FormalResult)
			// xtextResource.getContents().get(0);

			xmiResource.getContents().add(r.getContents().get(0));
			xmiResources.add(xmiResource);
		}

		for (Resource xmiResource : xmiResources) {
			try {
				xmiResource.save(null);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:[mwe2] unmapped paths platform:/resource/
Next Topic:Using forEach correctly
Goto Forum:
  


Current Time: Sat Nov 16 21:36:30 GMT 2019

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

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

Back to the top