Skip to content

How can I transform the xtext DSL elements into XML?

I have created a grammar using xtext, and generated the DSL. Now, I want to transform the DSL elements (program that is conforming to the grammar) to XML elements. So, I am wondering if there is a framework that allows to do that using Java for example. I could open the files having the extension of the DSL using the eclipse editor “Sample Reflective Ecore Model Editor” and could visualize the elements of the DSL. DdTe4.png

Answer

I found what I was looking for. I am using Xtend with Xtext. A “.xtend” file is generated once the grammar is compiled. This file contains a method called doGenerate. It is here where I am transforming my code which is conforming to its xtext grammar to a Capella XML and inject it directly in the “melodymodeller” Capella project file.

Thank you all for your answers.