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 03:49 Go to next message
Ashwani Kr Sharma is currently offline Ashwani Kr Sharma
Messages: 118
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 03: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 03:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6137
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
Re: Handling of boolean attributes while serialization [message #1028411 is a reply to message #1028404] Thu, 28 March 2013 04:07 Go to previous messageGo to next message
Ashwani Kr Sharma is currently offline Ashwani Kr Sharma
Messages: 118
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 04: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 04:51 Go to previous message
Ashwani Kr Sharma is currently offline Ashwani Kr Sharma
Messages: 118
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: Mon Jul 28 16:32:37 EDT 2014

Powered by FUDForum. Page generated in 0.04482 seconds