Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Import objects from XMI-based model into my DSL
Import objects from XMI-based model into my DSL [message #1230948] Mon, 13 January 2014 12:42 Go to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hello,

I have a simple DSL created. To reference to another metamodel I imported the referenced ecore, registered the package and genmodel. This works fine.

grammar address.AddressDSL with org.eclipse.xtext.common.Terminals

generate addressDSL "http://www.AddressDSL.address"

import "http://address" as address

Model:
	(imports+=Imports*)?
	greetings+=Greetings*;
	
Greetings:
	SimpleGreeting | PersonalGreeting
;
	
SimpleGreeting:
	'Hello' name=ID '!';
	
PersonalGreeting:
	'HelloP' person=[address::Person] '!';
	
Imports:
	'import' importURI=STRING ';' 



Now I generated all the code, got my editor and tried to load the XMI file from the imported ecore, to get my person ('mark'), which is the id of the "address::Person" using the statement import 'mark.address', where 'mark.address' this is the path to the file.

import "mark.address";

Hello Mark !
HelloP mark !


Now I got no autocompletion and typing simple 'mark' doesn't work and causes errors for 'HelloP'

What I want in general is the same behavior like the "Load Resources" action in the EMF editor. So 'HelloP mark !' should reference to the Person with id 'mark' in the XMI resource 'mark.address".

So my questions are:
- Does such an XMI import works out of the box in Xtext?
- Is this a case for extending the ScopeProvider?
- Do I have to load the Resource for my import URI 'mark.address' by myself, and where is the right place to load it?
- What else didn't I understand?


Thank you,
Mark
Re: Import objects from XMI-based model into my DSL [message #1230950 is a reply to message #1230948] Mon, 13 January 2014 12:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14082
Registered: July 2009
Senior Member
Hi,

you need to provide a resourceserviceprovider for the xmi as i describe it for eclipse uml xmis here http://christiandietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Import objects from XMI-based model into my DSL [message #1231426 is a reply to message #1230950] Tue, 14 January 2014 16:51 Go to previous messageGo to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Thank you Christian,

I got it work. Can you tell me please where the loading of the xmi resources happens?

If I understand the system right, the descriptors for the foreign xmi's come from the indexing, if the project is an xtext project. But I want to load the xmi from any location, using an path attribute (maybe using a file dialog) in the DSL model. What is the right class to do this? I read about the importURI mechanism, can I use this for it?

Mark
Re: Import objects from XMI-based model into my DSL [message #1231427 is a reply to message #1231426] Tue, 14 January 2014 16:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14082
Registered: July 2009
Senior Member
Hi,

it is hard to get non workspace things loaded. this is a general thing in xtext.
if its on the workspace or on the classpath of a java project - no problem.

for everything else: this goes beyond everything what i have seen in Xtext.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Import objects from XMI-based model into my DSL [message #1727726 is a reply to message #1231427] Fri, 25 March 2016 19:19 Go to previous messageGo to next message
Jack Burns is currently offline Jack BurnsFriend
Messages: 4
Registered: March 2016
Junior Member
Can someone update this for Xtext 2.9? The way it's shown in https://christia ndietrich.wordpress.com/2011/07/17/xtext-2-0-and-uml/ doesn't work anymore.
Re: Import objects from XMI-based model into my DSL [message #1727773 is a reply to message #1727726] Sun, 27 March 2016 08:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14082
Registered: July 2009
Senior Member
It Works basically the Same. Replace the Register Part with a referencedResource="..../abc.genmodel" Insider language

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Import objects from XMI-based model into my DSL [message #1727775 is a reply to message #1727773] Sun, 27 March 2016 08:48 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14082
Registered: July 2009
Senior Member
(see https://christiandietrich.wordpress.com/2012/08/07/xtext-referencing-elements-of-one-dsl-from-another-dsl/ for an example)

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:XText 2.9 Generated Scope Provider Class
Next Topic:Can't get scoping to work
Goto Forum:
  


Current Time: Wed Oct 27 17:46:52 GMT 2021

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

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

Back to the top