1. Home
  2. Docs
  3. Chapter 23. Document Production
  4. 5. Writing Doc. Composer element templates
  5. Beginning of template

Beginning of template

Every element template mush has <ElementBaseInitiationBlock>, <DiagramBaseInitiationBlock> or <ProjectBaseInitiationBlock> as root element.

The use of <ElementBaseInitiationBlock> is to tell the template engine that the template will be applied to a model element. If you are writing a template for a model element (e.g. use case, package…), use <ElementBaseInitiationBlock> as template root.

The use of <DiagramBaseInitiationBlock> is to tell the template engine that the template will be applied to a diagram. If you are writing a template for a diagram (e.g. Class Diagram…), use <DiagramBaseInitiationBlock> as template root.

The use of <ProjectBaseInitiationBlock> is to tell the template engine that the template will be applied to a project. If you are writing a template for a project, use <ProjectBaseInitiationBlock> as template root.
If you check back the example used in the previous section, you will find that the template was written to query the use cases from a diagram. The template will be applied on a diagram so <DiagramBaseInitiationBlock> was used as root element.

The following examples show the use of <ElementBaseInitiationBlock> and <ProjectBaseInitiationBlock> in templates.

<ElementBaseInitiationBlock>

    <!—Output the name of selected class-->
    <Property property="name"/>

</ElementBaseInitiationBlock>
<ProjectBaseInitiationBlock>

    <!—Output the name of all use cases in the project-->
    <IterationBlock allLevel="true" modelType="UseCase">
        <Property property="name"/>
    </IterationBlock>

</ProjectBaseInitiationBlock>