Java Reference
In-Depth Information
14.1 Xpand Language
Xpand templates are written in text files that end with an .xpt extension. An
Eclipse editor is provided for authoring templates, complete with syntax high-
lighting, code completion, and code templates. As guillemets (French quotation
marks, « and » ) are used as delimiters in the language, it's important to first con-
figure your environment to the right encoding. For PC installations of Eclipse,
use UTF-8 encoding; ISO-8859-1 works on Mac OS X. Furthermore, learn to use
Ctrl+< and Ctrl+> on the PC to type guillemots ( Alt+| and Alt+Shift+|
work on the Mac). Alternatively, you can use an empty «» template by pressing
Ctrl+spacebar.
Regarding the use of guillemets, when outputting text into a file, you can
remove trailing whitespace by adding a hyphen before the closing guillemot:
«...-» .
With the preliminaries out of the way, let's take a look at the Xpand language
itself. Each of the following sections covers the main elements of the language:
«IMPORT» , «DEFINE» , «EXPAND» , «FILE» , «FOREACH» , «EXTENSION» , «IF» ,
«PROTECT» , «LET» , «ERROR» , and «REM» .
14.1.1 IMPORT
At the top of an Xpand template, metamodel imports are listed using the
«IMPORT» statement. The concept of importing is similar to import statements
in Java and modeltype statements in OML. As with modeltype statements,
imports in Xpand let you declare metamodels by either their package or their
registered Eclipse Modeling Framework (EMF) Namespace URI (NS URI)
Uniform Resource Identifier (URI). In the case of their package, discovery of
models along the containing project's source path resolves the model declared.
This is a simple import statement for the Ecore metamodel:
« IMPORT ecore»
Alternatively, the import below uses the NS URI method, available in the
GMF Xpand implementation.
« IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
After a metamodel is imported, you can reference its elements throughout the
template without fully qualifying their names. Xpand currently does not have the
flexibility to assign an alias for use within the template, as you saw with QVT
OML.
 
Search WWH ::




Custom Search