we are using Xtext 2.2 to do implement our DSL. We manipulate the model in memory and persist the model as an xmi file using the EMF Resource.save() method. We would like to save the model in memory as text file using the DSL grammar we have specified with Xtext. How can we do this in Xtext 2.2? What is the code? I have not found an example in the documentation.
If I understand correctly all I should do is create a file with the extension of my registered DSL. In my case this is called "pogo". So if I create a file "myexample.pogo" instead of "myexample.xmi" I will have the model in the format of my DSL's grammar.
Aaron Digulla Messages: 241 Registered: July 2009 Location: Switzerland
The code is the same, no matter in which format you save your model. The trick is the file extension. It tells the framework in which format you want to save. If you use ".xml", you get an ecore XMI model. If you use ".foo" (if the extension for your DSL is "foo"), then the model will be saved in the "Foo" DSL.