Java Reference
In-Depth Information
When invoking a template, Xpand uses fully qualified namespaces, includ-
ing directory structures, the .xpt filename, and the «DEFINE» name. If this
example template were in a file named mindmap2csv.xpt within the folder
/templates/deploy , this «DEFINE» would be addressed as deploy::
mindmap2csv::Main from another template or the workflow used to execute the
template. This assumes that the /templates folder is set to a source path in the
project properties, or, in the case of GMF, that it is the folder specified as the
dynamic templates location.
14.1.3 EXPAND
The «EXPAND» statement directs execution to another «DEFINE» template block
or expands it, similar to invoking a subroutine. This is the general syntax for an
«EXPAND» statement:
« EXPAND definitionName [(parameterList)] [ FOR expression |
FOREACH expression [ SEPARATOR expression] ]»
The definitionName must be a fully qualified namespace, including the
filename and path, unless it's a «DEFINE» within the same file. In that case, a
simple name is sufficient. When referencing a «DEFINE» block outside the file, it
might be more convenient to add the appropriate IMPORT statement to the tem-
plate file. For example, let's say we wanted to modify our simple
mindmap2csv.xpt template to output a CSV file for Relationship elements, in
addition to the one for Topic elements. Our original «DEFINE» would then
include two «EXPAND» statements, as shown here. In this case, the Topic version
of the template is located in a directory /topic relative to a project source path
in a file named topic.xpt with a main «DEFINE» . The relationship template is
structured similarly.
« IMPORT mindmap»
« DEFINE Main FOR Map»
« EXPAND topic::topic::Main FOR this »
« EXPAND relationship::relationship::Main FOR this »
« ENDDEFINE »
Alternatively, if the topic and relationship folders were located below our
/template root folder, we could add IMPORT statements to our template and
shorten our «EXPAND» statements slightly.
Search WWH ::




Custom Search