Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

Creating a Template Fragment

A Template Fragment can return data from either an SQL Query, Model Scripts or Project Browser data. The process of defining the content of a Template Fragment depends on which of these types of data you want your Template Fragment to return, although in all cases the process is very similar to creating a normal document template.


Use one of the methods outlined here to open the 'New Document Template' dialog.


Publish > Documentation > Document Templates > New Template icon

Context Menu

Right-click on Package | Documentation | Generate Documentation > Templates : New

Keyboard Shortcuts

F8 > Templates : New


In the Resources window, expand the 'Document Generation' folder, then:

  • Expand the folder 'User Templates' | right-click on the folder 'Fragments' | Create Template or
  • Expand the folder 'User Templates' | expand the folder 'Fragments' | right-click on <template name> | Copy or
  • Expand the folder System Templates' | expand the folder 'Fragments' | right-click on <template name> | Copy

Create a new Template Fragment



See also


Using one of the methods above, display the 'New Document Template' dialog.

Document Templates


In the 'New Template' field, type the name for the Template Fragment.


In the 'Template Type' field, click on the drop-down arrow and select the 'Fragments' option.


In the 'Copy Template' field, click on the drop down arrow and select either:

  • 'None', to create an empty Template Fragment to develop from scratch, or
  • The name of an existing Template to act as a base


In the 'Template Group' field either:

  • Click on the drop-down arrow and select an existing group from the list, or
  • Type a name to generate a new template group, or
  • Leave this field blank, to not place the Template Fragment in a group

The Template Group determines the location of the Template Fragment in the Resources window.



Click on the OK button.

The Document Template Designer displays in the Diagram View.

Design Custom Document Templates


Define the contents of your Template Fragment; the actual steps you follow depend on the data type you want the Template Fragment to return:

  • Normal Document Template model data - the Template Fragment operates in the same way as a normal template
  • Custom SQL - returns data from a custom SQL query
  • Custom Scripts - returns data from a Model Script

Alternatively, if you want to use the Template Fragment to call other Fragments depending on element type, define it as a Template Selector.

Custom SQL Fragments Design Custom Document Templates Custom Script Fragments Define a Template Selector


Once you have created the Template Fragment, you incorporate it into a normal template (or into an existing Template Fragment, if you prefer).

Adding Fragments to a Document Template


  • As with normal document templates, Template Fragments can also be created and opened via the Resources window
  • Template Fragments in the Resources window are held in a Fragments folder in each of the Document Generation > System Templates and Document Generation > User Templates folders, and are indicated by a T symbol
  • If you have an existing template that you want to use as a Template Fragment, copy the template as the base of a new Fragment (as above)
  • If you embed a Template Fragment within another Fragment, report generation from the parent template will be slower

Learn more