Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Ecore model not properly registered(ecore model parsing string)
Ecore model not properly registered [message #1725048] Mon, 29 February 2016 10:56 Go to next message
Jose Ventura Roda is currently offline Jose Ventura RodaFriend
Messages: 6
Registered: April 2014
Junior Member
I've created a DSL with xtext 0.7

My goal is to parse a string with this dsl model, but i have some problem with the model registration.

When I try this code
URI dummy =URI.createURI("dummy:/example.cblData");
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource(dummy);
InputStream in = new ByteArrayInputStream(preprocessedCode.getBytes());
try {
	resource.load(in, resourceSet.getLoadOptions());
} catch (IOException e) {
	e.printStackTrace();
}

createResource method always returns null.

When I try this code
URI uriEasyFile = URI.createURI("file://C:/FAST_BP/_work/workspace/pru.cblData");
ResourceSet rs = new ResourceSetImpl();
Resource r = rs.getResource(uriEasyFile, true);

GetResource method thows "Cannot create a resource for 'file://C:/FAST_BP/_work/workspace/pru.cblData'; a registered resource factory is needed"

When I use the "Generic EMF From Editor" the model is opened correctly, but not from my class. Why don't found the Factory if the generic emf editor can open it?.

Thanks in advance.
Jose

Quote:
Edited for correct some copy/paste errors


[Updated on: Mon, 29 February 2016 11:10]

Report message to a moderator

Re: Ecore model not properly registered [message #1725051 is a reply to message #1725048] Mon, 29 February 2016 11:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14062
Registered: July 2009
Senior Member
You should call New
YourdslStandaloneSetup().createInjectorAnDoEmfRegistration() somewhere. And
the file extension is case sensitive


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: Ecore model not properly registered [message #1725052 is a reply to message #1725048] Mon, 29 February 2016 11:28 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 748
Registered: July 2009
Location: Dortmund, Germany
Senior Member

I'm not sure if the standalone setup already existed in Xtext 0.7. Are you really sure that it is the ancient version 0.7 and not something more up to date? If you use Xtext nowadays, Christian's answer to call the setup class is correct.

Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Ecore model not properly registered [message #1725055 is a reply to message #1725051] Mon, 29 February 2016 11:37 Go to previous messageGo to next message
Jose Ventura Roda is currently offline Jose Ventura RodaFriend
Messages: 6
Registered: April 2014
Junior Member
Christian you are right, now the code is:
URI dummy =URI.createURI("dummy:/example.cblData");
DataStandaloneSetup.doSetup();
Resource resource = resourceSet.createResource(dummy);
InputStream in = new ByteArrayInputStream(preprocessedCode.getBytes());
try {
	resource.load(in, resourceSet.getLoadOptions());
} catch (IOException e) {
	e.printStackTrace();
}


It run correctly.

Thanks!
Re: Ecore model not properly registered [message #1725056 is a reply to message #1725052] Mon, 29 February 2016 11:39 Go to previous message
Jose Ventura Roda is currently offline Jose Ventura RodaFriend
Messages: 6
Registered: April 2014
Junior Member
Karsten:
I know it's very old version, but i'm obliged for compatibility reasons. We are migrating but meanwhile...

Thanks

[Updated on: Mon, 29 February 2016 11:42]

Report message to a moderator

Previous Topic:JvmEnumerationLiteral has no support for parameters
Next Topic:Content assist when model is incomplete
Goto Forum:
  


Current Time: Sat Sep 18 05:39:04 GMT 2021

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

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

Back to the top