Skip to main content



      Home
Home » Modeling » TMF (Xtext) » generate a model .xmi xtext eclipse
generate a model .xmi xtext eclipse [message #1725923] Tue, 08 March 2016 09:12 Go to next message
Eclipse UserFriend

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 09:26 Go to previous messageGo to next message
Eclipse UserFriend
please any help
Re: generate a model .xmi xtext eclipse [message #1725930 is a reply to message #1725923] Tue, 08 March 2016 09:41 Go to previous messageGo to next message
Eclipse UserFriend
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 10:05 Go to previous messageGo to next message
Eclipse UserFriend
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 10:07 Go to previous messageGo to next message
Eclipse UserFriend
simply move the models content to a xmi resource an save it
Re: generate a model .xmi xtext eclipse [message #1725942 is a reply to message #1725937] Tue, 08 March 2016 10:13 Go to previous messageGo to next message
Eclipse UserFriend
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 10:15 Go to previous messageGo to next message
Eclipse UserFriend
what should trigger that? a java main, a command in eclipse?

btw why do you need the xmi at all?
Re: generate a model .xmi xtext eclipse [message #1725950 is a reply to message #1725944] Tue, 08 March 2016 10:29 Go to previous messageGo to next message
Eclipse UserFriend
do you have a single model file or multiple referenzing each other?
Re: generate a model .xmi xtext eclipse [message #1725952 is a reply to message #1725950] Tue, 08 March 2016 10:32 Go to previous messageGo to next message
Eclipse UserFriend
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 10:52 Go to previous messageGo to next message
Eclipse UserFriend
i need to have like this

[Updated on: Tue, 08 March 2016 10:52] by Moderator

Re: generate a model .xmi xtext eclipse [message #1725955 is a reply to message #1725954] Tue, 08 March 2016 10:53 Go to previous messageGo to next message
Eclipse UserFriend
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 10:56 Go to previous messageGo to next message
Eclipse UserFriend
The question is. What does the xpand Template do
Re: generate a model .xmi xtext eclipse [message #1725958 is a reply to message #1725956] Tue, 08 March 2016 10:59 Go to previous messageGo to next message
Eclipse UserFriend
And still the question what are inputs and ouputs
Re: generate a model .xmi xtext eclipse [message #1725959 is a reply to message #1725958] Tue, 08 March 2016 11:07 Go to previous messageGo to next message
Eclipse UserFriend
i don't unrestand ?
Re: generate a model .xmi xtext eclipse [message #1725961 is a reply to message #1725959] Tue, 08 March 2016 11:10 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: generate a model .xmi xtext eclipse [message #1725964 is a reply to message #1725961] Tue, 08 March 2016 11:17 Go to previous messageGo to next message
Eclipse UserFriend
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 11:42 Go to previous messageGo to next message
Eclipse UserFriend
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);
	}

}
Re: generate a model .xmi xtext eclipse [message #1726030 is a reply to message #1725968] Wed, 09 March 2016 02:10 Go to previous messageGo to next message
Eclipse UserFriend
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 02:18 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: generate a model .xmi xtext eclipse [message #1726040 is a reply to message #1726031] Wed, 09 March 2016 03:45 Go to previous messageGo to next message
Eclipse UserFriend
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 04:14 Go to previous messageGo to next message
Eclipse UserFriend
- 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)
Re: generate a model .xmi xtext eclipse [message #1726044 is a reply to message #1726042] Wed, 09 March 2016 04:20 Go to previous messageGo to next message
Eclipse UserFriend
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 04:23 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: generate a model .xmi xtext eclipse [message #1726067 is a reply to message #1726045] Wed, 09 March 2016 06:06 Go to previous messageGo to next message
Eclipse UserFriend
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 173 times)

[Updated on: Wed, 09 March 2016 06:10] by Moderator

Re: generate a model .xmi xtext eclipse [message #1726071 is a reply to message #1726067] Wed, 09 March 2016 06:42 Go to previous messageGo to next message
Eclipse UserFriend
how does your workflow look like
which xtext Version do you use?
did you have a look at the writer component as dennis suggested?
Re: generate a model .xmi xtext eclipse [message #1726072 is a reply to message #1726067] Wed, 09 March 2016 06:54 Go to previous messageGo to next message
Eclipse UserFriend
@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
Re: generate a model .xmi xtext eclipse [message #1726073 is a reply to message #1726071] Wed, 09 March 2016 07:12 Go to previous messageGo to next message
Eclipse UserFriend
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 07:15 Go to previous messageGo to next message
Eclipse UserFriend
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 07:22] by Moderator

Re: generate a model .xmi xtext eclipse [message #1726076 is a reply to message #1726074] Wed, 09 March 2016 07:39 Go to previous messageGo to next message
Eclipse UserFriend
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 08:22 Go to previous messageGo to next message
Eclipse UserFriend
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 09:43 Go to previous messageGo to next message
Eclipse UserFriend
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 10:35 Go to previous messageGo to next message
Eclipse UserFriend
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
}
}
Re: generate a model .xmi xtext eclipse [message #1726163 is a reply to message #1726103] Thu, 10 March 2016 04:13 Go to previous message
Eclipse UserFriend
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 Oct 31 18:36:27 EDT 2025

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

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

Back to the top