Formatting

Removing extra lines

All characters inside scripts are used for generation output, including spaces, line breaks, or carriage return characters.

Template content

Actual output

Expected output

AB
1 <gendoc>¶
2 ..[for (p:Package|self.ownedElement->filter(Package)->sortedBy(name))].¶
3 [p.name/].¶
4 ..[/for].¶
5 </gendoc>¶
AB
1
2 ...¶
3 Allocations.¶
4 ...¶
5 Context.¶
6 ...¶
7 LogicalView.¶
8 ...¶
9 PhysicalView.¶
10 ...¶
11 UseCases.¶
12 ...¶
13
AB
1 Allocations.¶
2 Context.¶
3 LogicalView.¶
4 PhysicalView.¶
5 UseCases.¶

<drop/> tag allows to remove extra rows.

Document generation is internally performed in two steps and <drop/> tag removes the WHOLE row in which it is contained so it must be handled with care.

First step is to analyze the lines to get as output to understand where the extra lines come from in the template and where the <drop/> tags should be located.

Template content

Output

AB
1 <gendoc>
2 ..[for (p:Package|self.ownedElement->filter(Package)->sortedBy(name))]
3 [p.name/].¶
4 ..[/for]
5 </gendoc>
AB
1
2 ..
3 Allocations.¶
4 ..
5 Context.¶
6 ..
7 LogicalView.¶
8 ..
9 PhysicalView.¶
10 ..
11 UseCases.¶
12 ..
13

Template content

before <drop/> handling

Final output

AB
1 <gendoc><drop/>¶
2 ..[for (p:Package|self.ownedElement->filter(Package)->sortedBy(name))].<drop/>¶
3 [p.name/].¶
4 ..[/for].<drop/>¶
5 </gendoc><drop/>¶
AB
1 <drop/>¶
2 ...<drop/>¶
3 Allocations.¶
4 ...<drop/>¶
5 Context.¶
6 ...<drop/>¶
7 LogicalView.¶
8 ...<drop/>¶
9 PhysicalView.¶
10 ...<drop/>¶
11 UseCases.¶
12 ...<drop/>¶
13 <drop/>¶
AB
1 Allocations.¶
2 Context.¶
3 LogicalView.¶
4 PhysicalView.¶
5 UseCases.¶

Removing lines with empty content

Tag <dropEmpty/> drop a paragraph if the tag content is empty.

The two following examples are equivalent:

AB
1 <context model=’${model_path}’/>
<gendoc><drop/>
2 All comments on packages:
3  [for (p:Package|Package.allInstances()->sortedBy(name))]
  [for (c:Comment| p.ownedComment)]<drop/>
4 - Comment for package [p.name/]: <dropEmpty>[c._body/]</dropEmpty>
5   [/for]
 [/for]
</gendoc><drop/>


AB
1 <context model=’${model_path}’/>
<gendoc><drop/>
2 All comments on packages:
3  [for (p:Package|Package.allInstances()->sortedBy(name))]
  [for (c:Comment| p.ownedComment)]
   [if (not(c._body.oclIsUndefined()))] <drop/>
4 - Comment for package [p.name/]: [c._body/]
5    [/if]
  [/for]
 [/for]
</gendoc><drop/>