The Xtext developers provide some good tutorials to get you started. In these, you will walk through the development of a simple (technical) language for describing data schemas or domain models: sets of entities with attributes and relationships between them. If you are not a programmer, then this example may look a little too technical, but it is worth noting that domain-specific modelling languages for other problem domain can be built with Xtext by following a very similar process.

  • This short tutorial aims to walk you through the basics of how to define a new language and use the fundamental Xtext concepts for this. It assumes that you have previously used Eclipse and have successfully installed Xtext. The final section on “packages and imports” may not be immediately relevant if you just want to get a basic sense of Xtext, but demonstrates how you can spread models over multiple files.
  • The extended tutorial builds on the short tutorial and shows how to make the new language useful. To this end, it
    1. Adds a code generator, which produces executable Java code from a model in our new domain-specific modelling language. Code generators are one important MDE technique for automating the production of software from models. In Xtext, code generators are often written in Xtend, a programming language built on Java. The tutorial provides an introduction to the Xtend concepts needed for building a first code generator. Note that many Xtend concepts are now also available in similar form in plain Java.
    2. Adds validation rules that automatically check consistency and validity of models in the new domain-specific modelling language. For example, this rule ensures uniqueness of names. Validations are important in MDE as they allow tools to give domain-specific feedback on models created by the users. Validations can be simple and technical as shown in the tutorial, but can also involve more complex analysis — a true strength of MDE.
    3. Adds automated tests for the language infrastructure. This is very useful, as it helps ensure that the language we are developing is working and any changes we make to it, do not accidentally break already established functionality.