mismatch between a grammar expression and its corresponding model [message #1750299] |
Mon, 19 December 2016 12:20  |
Eclipse User |
|
|
|
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 #1750382 is a reply to message #1750338] |
Tue, 20 December 2016 09:45  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06717 seconds