Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » mismatch between a grammar expression and its corresponding model
mismatch between a grammar expression and its corresponding model [message #1750299] Mon, 19 December 2016 17:20 Go to next message
Aran A is currently offline Aran AFriend
Messages: 30
Registered: January 2011
Member
Hi,

I've made some work with this simple grammar:
Model:
	'model' href=STRING
;
 

.. and I've problems with the model related to expressions conformant to this grammar.

I have coded a program that taking an expression conformant to the grammar (e.g. example.sedsl), it gets the *.xmi file with the model corresponding to that expression.

The content of example.sedsl is: model "http://amazon.com"

And the content of the corresponding xmi model is:

<?xml version="1.0" encoding="ASCII"?>
<selEvDsl:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:selEvDsl="..." href="http://amazon.com"/>


That is the content, if I open the *.xmi file with the Text Editor, everything seems ok, but if I open it with the "Sample Reflective Ecore Model Editor", the value of href attribute is null.

If I try to read the model with a Java program, I get the same, the null value for the href.

But, if I try to do same testing, with this xtend code
def void testCorrectParsing() {
 val model = '''
model "http://amazon.com" 
		'''.parse
	
		val name = model.href
		Assert::assertEquals("http://amazon.com", name)
		System.out.println(name)
		System.out.println(model.getHref())	
	}


The assert goes well, and besides I see the "http://amazon.com" value in the console.

I can't see why sometimes I get the string value and other times null. I got stuck, and I would appreciate any help.

Best regards,

Aran
Re: mismatch between a grammar expression and its corresponding model [message #1750303 is a reply to message #1750299] Mon, 19 December 2016 17:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 10337
Registered: July 2009
Senior Member
what do you do in your java program ?
Re: mismatch between a grammar expression and its corresponding model [message #1750338 is a reply to message #1750303] Tue, 20 December 2016 07:41 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 67
Registered: January 2016
Location: Kiel
Member

Hi Aran,

when you open the xmi with the reflective editor, so you see any error messages in the "Error Log" view or in the editor directly?
How is the selEvDsl namespace declared in the xmi? I could imagine that the meta model (ecore) is not properly found/loaded.

Sven

[Updated on: Tue, 20 December 2016 07:42]

Report message to a moderator

Re: mismatch between a grammar expression and its corresponding model [message #1750382 is a reply to message #1750338] Tue, 20 December 2016 14:45 Go to previous message
Aran A is currently offline Aran AFriend
Messages: 30
Registered: January 2011
Member
Hello,

I was preparing a long reply to show my code to get the model and the code to read it, and making more tries at the same time. And then, the light came to my mind!!

I have tried it and it worked!!! All the problem was a bad choice in the names, i.e. the use of "href" as the attribute name. Using another one, now I can open the model with both editors, and I can read the value of the attribute.

<?xml version="1.0" encoding="ASCII"?>
<selDsl:Model xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:selDsl="http://www.acmebi.org/projectbi/SelDsl" hrefa="http://yahoo.com/p"/>


Thanks for your support. Best regards,

Aran
Previous Topic:Whitespace in OpCompare's LessThan in Xbase grammar
Next Topic:Setting up Indigo with Xtext
Goto Forum:
  


Current Time: Thu Mar 30 16:59:25 GMT 2017

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

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