DevBooststLogotudLogorewerseLogo modelplexLogo
The fastest way to refinable, durable and evolution-resistant textual syntaxes for EMF models!


How do I change the look of my textual models?

There are two possibilities to change the highlighting:

  1. When you run your generated plugins in eclipse you can go to the preferences and to "EMFText Syntax Coloring". There you can define the look for each type of token and keyword in your language individually.
  2. The probably better solution is to use "TOKENSTYLES" in you CS specification. There you can define the default look for each of your token types and keywords. Look at this grammar (or at others in the zoo) for examples:


Note that some tokens are available by default (e.g., "TEXT" or "QUOTED_34_34" - for ['"','"']). You can see these tokens in the outline view.

How do I get an XMI version of my textual model?

This is simple: Open the file in the text editor generated for your language. Use File > Save as... and save the file at a new location with the extension "xmi". Done.

If you have two (or more) text syntaxes defined for your metamodel, which would have different file extensions, File > Save as... can also be used to convert models from one syntax to another.

If you want to do it programmatically, you can use code like this:

 // If you work outside Eclipse, you first have to register the different   
 // resource factories with EMF:
 //register <DSL>ResourceFactory for "dslExtension" file extension 
     ).put("dslExtension", new <DSL>ResourceFactory());
 //register XMI resource factory for all other extensions
         new XMIResourceFactoryImpl());
 // Then you can load and save resources in the different 
 // formats using a resource set:
 ResourceSet rs = new ResourceSetImpl();
 //load xmi resource
 Resource xmiResource = rs.getResource(
 //create an empty DSL resource (will be an instance of <DSL>Resource)
 Resource dslResource = rs.createResource(
 //transfer content from XMI to DSL resource
 //save the dsl resource (this will automatically use the <DSL>Printer); 

How can I use EMFText resources outside of Eclipse?

EMFText resources can be loaded without running Eclipse. To do so, the generated resource factory must be explicitly registered with the Ecore resource set. The following code shows how to load an EMFText resource and print all objects to System.out:

import java.util.Collections;
import java.util.Iterator;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

public class UseDSLOutsideEclipse {

	public static void main(String[] args) throws IOException {
		MyGeneratedResourceFactory factory = new MyGeneratedResourceFactory();

		ResourceSet rs = new ResourceSetImpl();
			"myFileExtension", factory
		Resource resource = rs.getResource(URI.createFileURI(
                                        "MyFile.myFileExtension"), true);
		Iterator<EObject> i = resource.getAllContents();
		while (i.hasNext()) {
			Object o =;

Can EMFText be used with the Eclipse Modeling Workflow Engine (MWE)?

EMFText implements the EMF resource API. Hence, in principle it is possible to transform models parsed by EMFText using MWE workflows and transformations based on Xpand and Xtend. By default, MWE workflows are not aware of generated resource factories. To register parsers generated by EMFText you may subclass the MWE Reader as follows:

public class Reader extends org.eclipse.emf.mwe.utils.Reader {
       public Reader(){

           //register your resource factory
               new <YOUR_LANGUAGE_NAME>ResourceFactory()
           //register all ecore models needed for reference resolving as follows:	

Note for EMFText 1.2.0: To parse xpt files, Xpand (as shipped with MWE 0.7.2) uses a version of the ANTLR runtime which is incompatible with the one used in EMFText 1.2.0. We have fixed this issue in later releases. If you really need to stick with EMFText 1.2.0, As a workaround, you may renamed the package names of the generated ANTLR runtime plugin to org.emftext.commons.antlr3_1_1.