Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » referencing existing ecore-model from xtext(Problems with referencing classes of ecore-model from dsl)
referencing existing ecore-model from xtext [message #1738439] Tue, 19 July 2016 20:40 Go to next message
Tatiana Wert is currently offline Tatiana WertFriend
Messages: 3
Registered: April 2016
Junior Member
Hello. I am using xtext 2.10. I created an EMF project with library.ecore model. The model consists of Library, Book and Author. Also I created xtext project org.xtext.example.mydsl which should use this ecore model. The grammar of my language:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate  ""

import "platform:/resource/org.example.library/model/library.ecore" as librarymodel
import ""

	ID ("." ID)*;
	'book' book = [librarymodel::Book|FullyQualifiedName]

I included library.genmodel as a referencedResource in my GenerateMyDsl.mwe2 :

var rootPath = ".."

Workflow {
	component = XtextGenerator {
		configuration = {
			project = StandardProjectConfig {
				baseName = "org.xtext.example.mydsl"
				rootPath = rootPath
				runtimeTest = {
					enabled = true
				eclipsePlugin = {
					enabled = true
				eclipsePluginTest = {
					enabled = true
				createEclipseMetaData = true
			code = {
				encoding = "windows-1251"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
		language = StandardLanguage {
			name = "org.xtext.example.mydsl.MyDsl"
			referencedResource = "platform:/resource/org.example.library/model/library.genmodel"
			fileExtensions = "mydsl"

			serializer = {
				generateStub = false
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"

After that I run a runtime application and create an instance of my library ecore model with several books and authors: mylibrary.library. I also created file test.mydsl and I would like to reference books from mylibrary.library. However, the content assist is empty and mylibrary-objects are not referenceable.
What am I missing? How can I reference objects of ecore-model-instances from mydsl file.

[Updated on: Tue, 19 July 2016 20:43]

Report message to a moderator

Re: referencing existing ecore-model from xtext [message #1738440 is a reply to message #1738439] Tue, 19 July 2016 20:46 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14655
Registered: July 2009
Senior Member
If you want to reference non xtext models from xtext you need to provide a
I resourceserviceprovider for that. An example describing the idea can be
found here

Twitter : @chrdietrich
Blog :
Previous Topic:Problem with ecore and the new generator
Next Topic:[SOLVED] XtextBuilder issue with a created project from existing model
Goto Forum:

Current Time: Mon Mar 04 06:25:40 GMT 2024

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

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

Back to the top