Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Handling of boolean attributes while serialization(Handling of boolean attributes while serialization)
Handling of boolean attributes while serialization [message #1028396] Thu, 28 March 2013 07:49 Go to next message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 119
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi,

Scenario:
I have a use case of reading from xmi to ecore model and then serializing it in xText model and then to a file.

Details:
Hence, i load emf model from xmi file.
There is attribute "public", type boolean in EClass "Attribute" which contains value "false" in the emf model.

Them xText grammer i have following rule:
Attribute returns Attribute:
	(public?='public')? 'Attribute' name=ID


I am serializing this model to xtext representation in the file via following code:
Injector injector = Guice.createInjector(new ControllerDslRuntimeModule());
XtextResourceSet set = injector.getInstance(XtextResourceSet.class);

XtextResource xtextResource = (XtextResource) set.getResource(targeturi, true);
xtextResource.getContents().add(controllerForXText);
try {
	// save it the new file
	Map<Object, Object> optionsMap = SaveOptions.defaultOptions().toOptionsMap();
		optionsMap.put(XtextResource.OPTION_ENCODING, "UTF-8");
		xtextResource.save(optionsMap);
	} catch (IOException e) {
		e.printStackTrace();
}


Since in the model the value of public was false i expected that in the dsl file keyword "public" should not appear.
But it is always there.
public Attribute attr1


What exactly what i am missing here ?
Any hint will be helpful.

Thanks and Regards,
Ashwani Kr Sharma

[Updated on: Thu, 28 March 2013 07:56]

Report message to a moderator

Re: Handling of boolean attributes while serialization [message #1028404 is a reply to message #1028396] Thu, 28 March 2013 07:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14668
Registered: July 2009
Senior Member
Hi sounds like a bug to me ( if the value really is false - did you
double check that)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Handling of boolean attributes while serialization [message #1028411 is a reply to message #1028404] Thu, 28 March 2013 08:07 Go to previous messageGo to next message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 119
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi,

I checked content of xmi file using Sample Reflective Ecore Model. The editor shows the value is false.

I also debugged and checked the value in the model. There also the value is false.

Once i serialize and then load the model again from persisted dsl file the value is read as true.
I am using xText 2.4.0
Can i do something as quick win or workaround?

Regards,
Ashwani Kr Sharma

[Updated on: Thu, 28 March 2013 08:23]

Report message to a moderator

Re: Handling of boolean attributes while serialization [message #1028437 is a reply to message #1028411] Thu, 28 March 2013 08:51 Go to previous message
Ashwani Kr Sharma is currently offline Ashwani Kr SharmaFriend
Messages: 119
Registered: July 2009
Location: Bangalore, India
Senior Member

Hi,

I created a bug for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=404532

Regards,
Ashwani Kr Sharma
Previous Topic:Xtext Grammar based on an already existing ecore diagram
Next Topic:Xtext: Referencing Elements of one DSL from another DSL Problem
Goto Forum:
  


Current Time: Fri Apr 26 19:09:43 GMT 2024

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

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

Back to the top