Java Reference
In-Depth Information
org.eclipse.xtend;bundle-version="0.7.0",
org.eclipse.xtend.typesystem.emf;bundle-version="0.7.0",
org.eclipse.emf.mwe.core;bundle-version="0.7.0",
org.eclipse.emf.mwe.utils;bundle-version="0.7.0",
org.apache.commons.cli;bundle-version="1.0.0",
org.apache.commons.lang;bundle-version="2.1.0",
org.eclipse.emf.ecore.xmi;bundle-version="2.4.0",
org.apache.commons.logging;bundle-version="1.0.4",
org.antlr.runtime;bundle-version="3.0.0"
A final note on using Xpand in our sample projects concerns the GMF vari-
ant in your environment. Until the enhancements made to Xpand for GMF are
merged into the new M2T Xpand component, you will find another registered
editor on the right-click Open With menu. Both editors are functional and can
be used to develop Xpand templates. The most visible difference is the capabil-
ity of the GMF version to work with NS URI import statements instead of rely-
ing on source paths in the project. GMF's Xpand also adds the notion of Xpand
roots, preserved in .xpand-roots files in the workspace. Finally, GMF's Xpand
leaves the direction of text generated by a template to a particular location to the
workflow, not to FILE directives within a template.
Having completed the preliminary introduction to Xpand, Xtend, and
Workflow elements found in your environment, let's move on to developing tem-
plates for our sample projects. You can find more information on these tech-
nologies in Chapter 14, “Xpand Template Language.”
7.2 Generating CSV Files
To begin with the simplest example imaginable, we use Xpand here to output a
simple comma-separated values (CSV) file from our mindmap model. The first
step is to create a template in a /templates/deploy source folder of our
org.eclipse.dsl.mindmap project named mindmap2csv.xpt and complete
it with the following text:
« IMPORT mindmap»
« DEFINE Main FOR Map»
« FILE (title == null ? "map" : title) + ".csv"-»
« FOREACH elements.typeSelect(mindmap::Topic) AS topic-»
«topic.name»,«topic.priority»,«topic.start»,«topic.end»
« ENDFOREACH »
« ENDFILE »
«ENDDEFINE»
The template begins with a simple import of our mindmap model and the
definition of a template named Main that operates on a passed-in Map instance,
 
Search WWH ::




Custom Search