If for instance the generation tools are not powerful enough to support a
mapping from models to the required text in one step, intermediate phases may be
useful. Similarly, if there already exist tried and tested transformations from a
certainmodel format to code, itmaybe useful to translateDSMmodels to thatmodel
format. Particularly where these transformations cross tool boundaries, however,
there is a danger of information being lost or twisted along the way, like a game of
Chinese Whispers.
11.2.3 Output Template
An output template consists of the code you want as an output, but with parts that vary
based on the model replaced by commands surrounded by some escape character
sequence. This approach is familiar fromweb pages built dynamically on the client side
with HTML containing JavaScript commands, or on the server side with PHP or ASP.
Template-based generators are probably the most common kind, and one of the
oldest. Examples include JET (Java Emitter Templates), the Microsoft DSLTools T4
engine, and the CodeWorker scripting language.
JET operates on input data consisting of a single Java object, and its command
sequences are written in normal Java. It can only be run as part of Eclipse and is only
designed for outputting Java classes. It uses <% and %> to escape its command
sequences??”the escape characters can be con?¬?gured??”and also <%?? and %> to
delimit a Java expression whose result is appended directly to the output.
Pages:
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502