Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » generate a model .xmi xtext eclipse
generate a model .xmi xtext eclipse [message #1725923] Tue, 08 March 2016 14:12 Go to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member

how to generate a model .xmi xtext eclipse ? . I have the metamodel .ecore.
Re: generate a model .xmi xtext eclipse [message #1725926 is a reply to message #1725923] Tue, 08 March 2016 14:26 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
please any help
Re: generate a model .xmi xtext eclipse [message #1725930 is a reply to message #1725923] Tue, 08 March 2016 14:41 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

An Ecore file is an XMI file.

No idea what Xtext or Eclipse has to do with it?

Regards

Ed Willink


On 08/03/2016 14:12, salha salha wrote:
>
> how to generate a model .xmi xtext eclipse ? . I have the metamodel
> .ecore.
Re: generate a model .xmi xtext eclipse [message #1725936 is a reply to message #1725930] Tue, 08 March 2016 15:05 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
i ask about how i get a model with an extention .xmi with an exemple of dsl
Re: generate a model .xmi xtext eclipse [message #1725937 is a reply to message #1725936] Tue, 08 March 2016 15:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
simply move the models content to a xmi resource an save it

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1725942 is a reply to message #1725937] Tue, 08 March 2016 15:13 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
how i do that i'm bigginer ?
Re: generate a model .xmi xtext eclipse [message #1725944 is a reply to message #1725942] Tue, 08 March 2016 15:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
what should trigger that? a java main, a command in eclipse?

btw why do you need the xmi at all?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1725950 is a reply to message #1725944] Tue, 08 March 2016 15:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
do you have a single model file or multiple referenzing each other?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1725952 is a reply to message #1725950] Tue, 08 March 2016 15:32 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
you don't unrestand me i give you an exemple one minute
Re: generate a model .xmi xtext eclipse [message #1725954 is a reply to message #1725952] Tue, 08 March 2016 15:52 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
i need to have like this

[Updated on: Tue, 08 March 2016 15:52]

Report message to a moderator

Re: generate a model .xmi xtext eclipse [message #1725955 is a reply to message #1725954] Tue, 08 March 2016 15:53 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
srcGen i don't know how generate the model .xmi
Re: generate a model .xmi xtext eclipse [message #1725956 is a reply to message #1725955] Tue, 08 March 2016 15:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
The question is. What does the xpand Template do

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1725958 is a reply to message #1725956] Tue, 08 March 2016 15:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
And still the question what are inputs and ouputs

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1725959 is a reply to message #1725958] Tue, 08 March 2016 16:07 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
i don't unrestand ?
Re: generate a model .xmi xtext eclipse [message #1725961 is a reply to message #1725959] Tue, 08 March 2016 16:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
What is the input? Is it a xtext based model? If yes is the mets model the same as for the output?
And how do you tell the system please use these inputs and save them as xmi.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1725964 is a reply to message #1725961] Tue, 08 March 2016 16:17 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
i write my dsl and i generate it . it give me a metamodel .ecore
Re: generate a model .xmi xtext eclipse [message #1725968 is a reply to message #1725964] Tue, 08 March 2016 16:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi i sill did not a single answer to my questions ?!?

import java.io.IOException;
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.xtext.example.mydsl1.MyDslStandaloneSetup;

import com.google.inject.Injector;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
		ResourceSet resourceSet = injector.getInstance(ResourceSet.class);
		Resource resource = resourceSet.getResource(URI.createURI("models/test.mydsl1"), true);
		resource.load(null);
		EcoreUtil.resolveAll(resourceSet);
		Resource xmiResource = resourceSet.createResource(URI.createURI("models/result.xmi"));
		xmiResource.getContents().add(resource.getContents().get(0));
		xmiResource.save(null);
	}

}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1726030 is a reply to message #1725968] Wed, 09 March 2016 07:10 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi Christian,

perhaps you can give all newbies like me a little more info beside just the code:
- what is the file name?
- is this a new file we have to create of just an amendment to an existing file?
- How is the complete show started

I know these "stupid" questions drive experts crazy, but without asking, no gain.
Re: generate a model .xmi xtext eclipse [message #1726031 is a reply to message #1726030] Wed, 09 March 2016 07:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

this is why i asked all the questions. and if i dont get an answer i do the minimal thing and hardcode.

if i dont get requirements i cannot propose all 10^10 possible Solutions.
it is a Java main so it is obvious how it is started


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1726040 is a reply to message #1726031] Wed, 09 March 2016 08:45 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
For you it may be obvious, but as I asked these questions, it is not for me (and a lot of other people as well)
So to be for any use for me: Please answer my question.
Re: generate a model .xmi xtext eclipse [message #1726042 is a reply to message #1726040] Wed, 09 March 2016 09:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
- what is the file name?
The File Name in Main.java

- is this a new file we have to create of just an amendment to an existing file?
- create a new one somewhere you like

- How is the complete show started
- run it as Java application (main)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1726044 is a reply to message #1726042] Wed, 09 March 2016 09:20 Go to previous messageGo to next message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Hi Dietrich,
thank you for this additional Information.
I will check it today.

"Vielen Dank aus Frankfurt", Uli
Re: generate a model .xmi xtext eclipse [message #1726045 is a reply to message #1725954] Wed, 09 March 2016 09:23 Go to previous messageGo to next message
Dennis Huebner is currently offline Dennis HuebnerFriend
Messages: 257
Registered: July 2009
Senior Member

Xpand, Xtend 1 and MWE 1 is used. It became interesting.

@salha salha is that your project?
Could you please paste here the content of GramBPELGenerator.mwe?

I additional look at org.eclipse.emf.mwe.utils.Writer



+Dennis Huebner

Get professional support from the Xtext committers at www.typefox.io
Re: generate a model .xmi xtext eclipse [message #1726067 is a reply to message #1726045] Wed, 09 March 2016 11:06 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
hi no it 's not what i ask about in the project i have an example wsm.ac when i run the generatot in workflow i should have a file in src-gen with extention .xmi
  • Attachment: boubou.png
    (Size: 22.23KB, Downloaded 134 times)

[Updated on: Wed, 09 March 2016 11:10]

Report message to a moderator

Re: generate a model .xmi xtext eclipse [message #1726071 is a reply to message #1726067] Wed, 09 March 2016 11:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
how does your workflow look like
which xtext Version do you use?
did you have a look at the writer component as dennis suggested?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: generate a model .xmi xtext eclipse [message #1726072 is a reply to message #1726067] Wed, 09 March 2016 11:54 Go to previous messageGo to next message
Dennis Huebner is currently offline Dennis HuebnerFriend
Messages: 257
Registered: July 2009
Senior Member

@salha salha
Export your projects as zip file (right click with the mouse -> select export menu entry ) and attach it here.
And we can play "who finds out what to do!"-game



+Dennis Huebner

Get professional support from the Xtext committers at www.typefox.io
Re: generate a model .xmi xtext eclipse [message #1726073 is a reply to message #1726071] Wed, 09 March 2016 12:12 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
Xtext Documentation
Version: 1.0.2.v201102150722
Re: generate a model .xmi xtext eclipse [message #1726074 is a reply to message #1726073] Wed, 09 March 2016 12:15 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
i think that i should modify here
module workflow.MyDslGenerator

import org.eclipse.emf.mwe.utils.*

var targetDir = "src-gen"
var fileEncoding = "Cp1252"
var modelPath = "src/model"

Workflow {

component = org.eclipse.xtext.mwe.Reader {
// lookup all resources on the classpath
// useJavaClassPath = true

// or define search scope explicitly
path = modelPath

// this class will be generated by the xtext generator
register = org.xtext.example.mydsl.MyDslStandaloneSetup {}
load = {
slot = "greetings"
type = "Greeting"
}
}

component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH greetings"
outlet = {
path = targetDir
}
fileEncoding = fileEncoding
}
}

[Updated on: Wed, 09 March 2016 12:22]

Report message to a moderator

Re: generate a model .xmi xtext eclipse [message #1726076 is a reply to message #1726074] Wed, 09 March 2016 12:39 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
i think that i should modify here
module workflow.MyDslGenerator

import org.eclipse.emf.mwe.utils.*

var targetDir = "src-gen"
var fileEncoding = "Cp1252"
var modelPath = "src/model"

Workflow {

component = org.eclipse.xtext.mwe.Reader {
// lookup all resources on the classpath
// useJavaClassPath = true

// or define search scope explicitly
path = modelPath

// this class will be generated by the xtext generator
register = org.xtext.example.mydsl.MyDslStandaloneSetup {}
load = {
slot = "greetings"
type = "Greeting"
}
}

component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH greetings"
outlet = {
path = targetDir
}
fileEncoding = fileEncoding
}
}
Re: generate a model .xmi xtext eclipse [message #1726081 is a reply to message #1726076] Wed, 09 March 2016 13:22 Go to previous messageGo to next message
salha salha is currently offline salha salhaFriend
Messages: 97
Registered: February 2016
Member
when i run the work flow i got this error
0 [main] DEBUG org.eclipse.xtext.mwe.Reader - Resource Pathes : [src/model]
0 [main] INFO org.eclipse.xpand2.Generator - No meta models configured, using JavaBeans as default.
955 [main] DEBUG xt.validation.ResourceValidatorImpl - Syntax check OK! Resource: file:/D:/Nouveau%20dossier/eclipsehelio%20avec%20atl/workspace/org.xtext.example.ac.generator/src/model/Example.ac
1838 [main] DEBUG xt.validation.ResourceValidatorImpl - Syntax check OK! Resource: file:/D:/Nouveau%20dossier/eclipsehelio%20avec%20atl/workspace/org.xtext.example.ac.generator/src/model/wsm.ac
2054 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems running workflow workflow.MyDslGenerator: Couldn't find EClass for name 'Greeting'.
java.lang.RuntimeException: Problems running workflow workflow.MyDslGenerator: Couldn't find EClass for name 'Greeting'.
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:82)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: org.eclipse.emf.mwe.core.WorkflowInterruptedException: Couldn't find EClass for name 'Greeting'.
at org.eclipse.xtext.mwe.SlotEntry.findEClasses(SlotEntry.java:116)
at org.eclipse.xtext.mwe.SlotEntry.put(SlotEntry.java:76)
at org.eclipse.xtext.mwe.AbstractReader.addModelElementsToContext(AbstractReader.java:87)
at org.eclipse.xtext.mwe.Reader.invokeInternal(Reader.java:166)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:31)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:80)
... 3 more
Re: generate a model .xmi xtext eclipse [message #1726093 is a reply to message #1726081] Wed, 09 March 2016 14:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

To short-circuit this kind of non-communication on the OCL newsgroup I
wrote and regularly refer to:

https://wiki.eclipse.org/OCL/ForumNetiquette

You might find that it helps you understand how to get a much more rapid
response.

Regards

Ed Willink


On 09/03/2016 13:22, salha salha wrote:
> when i run the work flow i got this error 0 [main] DEBUG
> org.eclipse.xtext.mwe.Reader - Resource Pathes : [src/model]
> 0 [main] INFO org.eclipse.xpand2.Generator - No meta
> models configured, using JavaBeans as default.
> 955 [main] DEBUG xt.validation.ResourceValidatorImpl - Syntax check
> OK! Resource:
> file:/D:/Nouveau%20dossier/eclipsehelio%20avec%20atl/workspace/org.xtext.example.ac.generator/src/model/Example.ac
> 1838 [main] DEBUG xt.validation.ResourceValidatorImpl - Syntax check
> OK! Resource:
> file:/D:/Nouveau%20dossier/eclipsehelio%20avec%20atl/workspace/org.xtext.example.ac.generator/src/model/wsm.ac
> 2054 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems
> running workflow workflow.MyDslGenerator: Couldn't find EClass for
> name 'Greeting'.
> java.lang.RuntimeException: Problems running workflow
> workflow.MyDslGenerator: Couldn't find EClass for name 'Greeting'.
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:82)
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
> Caused by: org.eclipse.emf.mwe.core.WorkflowInterruptedException:
> Couldn't find EClass for name 'Greeting'.
> at org.eclipse.xtext.mwe.SlotEntry.findEClasses(SlotEntry.java:116)
> at org.eclipse.xtext.mwe.SlotEntry.put(SlotEntry.java:76)
> at
> org.eclipse.xtext.mwe.AbstractReader.addModelElementsToContext(AbstractReader.java:87)
> at org.eclipse.xtext.mwe.Reader.invokeInternal(Reader.java:166)
> at
> org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
> at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
> at
> org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
> at
> org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:31)
> at
> org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:80)
> ... 3 more
>
Re: generate a model .xmi xtext eclipse [message #1726103 is a reply to message #1726093] Wed, 09 March 2016 15:35 Go to previous messageGo to next message
Dennis Huebner is currently offline Dennis HuebnerFriend
Messages: 257
Registered: July 2009
Senior Member

I would guess it could be:
component = org.eclipse.xpand2.Generator {
expand = "templates::Template::main FOREACH greetings"
metaModel = org.eclipse.xtend.typesystem.emf.EmfMetaModel {
metaModelPackage = "org.xtext.example.ac.<Something>Package"
}

outlet = {
path = targetDir
}
fileEncoding = fileEncoding
}
}



+Dennis Huebner

Get professional support from the Xtext committers at www.typefox.io
Re: generate a model .xmi xtext eclipse [message #1726163 is a reply to message #1726103] Thu, 10 March 2016 09:13 Go to previous message
Uli Merkel is currently offline Uli MerkelFriend
Messages: 250
Registered: June 2013
Senior Member
Some newbies like me may find this code with just a little bit of comment helpful to reproduce:
// file: /org.xtext.example.mydsl/src/org/xtext/example/mydsl/Main.java
//
// This example is done using the
// eclipse-dsl-mars-1 distribution with the 
// xtext_2.8.4.v201508050135
//
// we use the standards for a new xtext project which creates a project as: org.xtext.example.mydsl
// and we generate the xtext artifacts running the GenerateMyDsl.mwe2
//
// under the project, we create a new folder "models_xmi" for DSL files as well as the generated xmi files
// in that directory, we create DSL file testMYDSL.mydsl as:
/*
Hello PAUL!
Hello Peter!
Hello Martin!
*/
// in src/org.xtext.example.mydsl we create a new Java Class with name "Main" 
// and check "public static void main(String[] args)" in the wizard

// and this is the code in this Main.java file (note the "throws Exception")
// 
package org.xtext.example.mydsl;

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 com.google.inject.Injector;

public class Main {

	public static void main(String[] args) throws Exception{
		Injector injector = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
		ResourceSet resourceSet = injector.getInstance(ResourceSet.class);
		// this is our source DSL file "testMYDSL.mydsl" in folder "models_xmi"
		/*
		Hello PAUL!
		Hello Peter!
		Hello Martin!
		 */
		Resource resource = resourceSet.getResource(URI.createURI("models_xmi/testMYDSL.mydsl"), true);
		resource.load(null);
		EcoreUtil.resolveAll(resourceSet);
		// and this is the corresponding xmi file "testMYDSL.xmi" in folder "models_xmi":
		/*
		<?xml version="1.0" encoding="ASCII"?>
		<myDsl:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:myDsl="http://www.xtext.org/example/mydsl/MyDsl">
  		<greetings name="PAUL"/>
  		<greetings name="Peter"/>
  		<greetings name="Martin"/>
		</myDsl:Model>
 		 */
		Resource xmiResource = resourceSet.createResource(URI.createURI("models_xmi/testMYDSL.xmi"));
		xmiResource.getContents().add(resource.getContents().get(0));
		xmiResource.save(null);
	}
}
Previous Topic:Using NeoEMF with Xtext
Next Topic:Embedding Xtext Editors in Forms
Goto Forum:
  


Current Time: Fri Apr 19 08:28:04 GMT 2024

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

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

Back to the top