Besides element template, there is another tool to query project data and place it onto a document, called the Loop tool. You can access the Loop tool under the Element Template Pane.
The Loop tool is capable in querying children element of element selected in Diagram Navigator / Model Explorer. When you select and drag the Loop tool onto a document, you will be prompted to configure the Loop, like this:
Items listed under the Elements tab are children elements of the element selected in Diagram Navigator / Model Explorer. For example, if you have selected a diagram, you can expect the diagram elements being listed here.
Content will be added to document for each of the elements listed. The content to produce is determined by an element template. You can select the template under the Element Types tab.
The left hand side of the Element Types tab lists the types of elements found by the loop while the right hand side lists the element template to be chosen for content creation. By default the Basic template is chosen for all element types. This means that for each of the elements under the Elements tab, content will be produced and added to the document based on the Basic template. You can select another template by click on Basic and make a selection.
Excluding Elements and Element Types
Sometimes, you may not want to produce content for all elements returned by a loop, but only some of the elements. For example, when you create a use case specification, you may not want to process the actors when looping under a Use Case Diagram. For such cases, you can exclude the elements or types of element that are not needed in content creation.
You can exclude an element, or a type of element. To exclude an element, move your mouse pointer over that element under the Elements tab and the click on the Exclude button on the right hand side of the hovering row.
To exclude an element type, open the Element Types tab and move your mouse pointer over the type to exclude, then click on the Exclude button.
If you want to remove an element or element type from the exclude list, open the Excluded tab, move your mouse pointer over the item to be removed and then click on the Include button on the right hand side of the hovering row.
To re-order elements, click on the Sorting drop down menu at the top of the New Loop window and select the way to sort.
Here are a description of the various types of sorting method:
|System||Elements are sorted according to the system’s default setting.|
|Name||Sort by elements’ name in alphabetical order.|
|Model Type||Sort by element type. You can customize the sort order in the Element Types tab.|
|Manual||Order the elements yourself.|
Saving a Loop Template
Although Loop itself is tool instead of a template, you can produce a template from it. Doing so allows you to customize the template further by editing the loop in XML form. To produce a loop template, right click on any content block produced with the Loop tool and select Save as Loop Template from the popup menu.
You will be prompted for a template name. Enter the name and confirm. When finished you will find a new template listed in the Element Templates Pane. You can customize it and re-use it in creating content. For details about writing a template, please read Writing Your Template.