0

我正在尝试通过 uml 生成 html 文档,并且一切正常。我的问题是我会将所有报告附在:

<html>
  <body>
       //report
  </body>
</html>

我怎样才能做到这一点?

这是我要附上的 acceleo 报告模板:

[comment encoding = UTF-8 /]
[module useCase('http://www.eclipse.org/uml2/3.0.0/UML')]

[template public generateUseCase(uc : UseCase)]
[comment @main/]

[file (('useCases.html'), true)]

<h1>UseCase: [uc.name/]</h1>
[if (uc.ownedBehavior->notEmpty())]
<h5>Part of Activity: [uc.ownedBehavior.name/]</h5>
[/if]
<h3>Extension Points:</h3>
[if (uc.extensionPoint->isEmpty())]
<p>No Extension Points</p>
[/if]
<ul>
[for (e : ExtensionPoint | uc.extensionPoint)]
 <li>[e.name/]</li>
[/for]
</ul>
[/file]
[/template]
4

1 回答 1

1

斯特凡诺,

细分您的模板始终是可能的(也是建议的)。在这里,您可以使用循环,而不是为遇到的每个新用例附加文件:

[template public generate(p : Package)]
[comment @main/]

[file (('useCases.html'), false)]
<html>
  <body>
[for (uc : UseCase | p.eAllContents(UseCase))]
    [generateUseCase(uc)/]
[/for]
  </body>
</html>
[/file]
[/template]

[template public generateUseCase(uc : UseCase)]
<h1>UseCase: [uc.name/]</h1>
[if (uc.ownedBehavior->notEmpty())]
<h5>Part of Activity: [uc.ownedBehavior.name/]</h5>
[/if]
<h3>Extension Points:</h3>
[if (uc.extensionPoint->isEmpty())]
<p>No Extension Points</p>
[/if]
<ul>
[for (e : ExtensionPoint | uc.extensionPoint)]
 <li>[e.name/]</li>
[/for]
</ul>
[/template]

请注意,像我在这里所做的那样使用“eAllContents”远非有效,您可能希望手动导航到您的用例列表。

于 2013-11-22T07:49:22.733 回答