Create an ordinary Xpand Template file: Being in the Xpand/Xtend perspective, go to "File", "New", "xPand template" . The Xpand language itself is explained by several other Xpand documents. Having XSD meta model support activated like described in the section called “Step 1: Create a Project” , Xpand scans and watches all it's projects for suitable meta models. Based on what is found, the Xpand editor provides meta model aware code completion.
This example imports "metamodel" at the
beginning, which refers to a file called
metamodel.xsd that you have created within the
project's classpath in the section called “Step 2: Define a Meta Model using XML Schema” . The
define-block can be understood as a function named
"Root" which takes one object of type
metamodel::Wizard as a parameter. This is the meta
model's type for the XML's root object. The file-block creates a file
named wizard.txt and writes the text that is
surrounded by the file-block into the file. name ,
welcometext and
choicepage.title are elements or attributes defined
in the XSD meta model. Their values are stored within the XML file and
this templates inserts them into the generated (
wizard.txt ) file.
«IMPORT metamodel» «DEFINE Root FOR metamodel::Wizard» «FILE "wizard.txt"» Name: «name» Welcometext: «welcometext» First Page Title: «choicepage.title» «ENDFILE» «ENDDEFINE»