If you need to loop or iterate through a set of Objects that are contained within or are under the current object, you can do so using the %list macro. This macro performs an iterative pass on all the objects in the scope of the current template, and calls another template to process each one.
The basic structure is:
%list=<TemplateName> @separator=<string> @indent=<string> ( <conditions> ) %
where <string> is a double-quoted literal string and <TemplateName> can be one of the following template names:
|•||Custom Template (custom templates enable you to define your own templates)|
<conditions> is optional and looks the same as the conditions for if and elseIf statements.
In a Class transform, the Class might contain multiple Attributes; the following example calls the Attribute transform and outputs the result of processing the transform for each attribute of the Class in scope. The resultant list separates its items with a single new line and indents them two spaces respectively. If the Class in scope had any stereotyped attributes, they would be generated using the appropriately specialized template.
%list="Attribute" @separator="\n" @indent=" "%
The separator attribute, denoted above by @separator, specifies the space that should be used between the list items, excluding the last item in the list.
The indent attribute, denoted by @indent, specifies the space by which each line in the generated output should be indented.
There are some special cases to consider when using the %list macro:
|•||If the Attribute template is used as an argument to the %list macro, this also generates attributes derived from Associations by executing the appropriate LinkedAttribute template|
|•||If the ClassBase template is used as an argument to the %list macro, this also generates Class bases derived from links in the model by executing the appropriate LinkedClassBase template|
|•||If the ClassInterface template is used as an argument to the %list macro, this also generates Class bases derived from links in the model by executing the appropriate LinkedClassInterface template|
|•||If InnerClass or InnerClassImpl is used as an argument to the %list macro, these Classes are generated using the Class and ClassImpl templates respectively; these arguments direct that the templates should be processed based on the inner Classes of the Class in scope|
The material ("material" includes all pages, documents and on-line graphics) on this web site is protected by copyright law. (C) 1998-2014 Sparx Systems Pty Ltd.