List Macro
The %list macro performs an iterative pass on all the objects in the scope of the current template, and calls a template to process each of these.
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 appears the same as the conditions for if and elseIf statements.
Example
The List command is the method to loop or iterate through a set of Objects that are contained or are under the current object.
For instance, 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.
Special Cases:
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 tell Enterprise Architect that it should process the templates based on the inner Classes of the Class in scope |
Learn more
The material ("material" includes all pages, documents and on-line graphics) on this web site is protected by copyright law. (C) 1998-2011 Sparx Systems Pty Ltd.