Mastering EA Document Style Sheets

by Phil Chudley

 

Introduction

In order to provide a consistent look-and-feel to documents (RTF/DOCX/PDF) produced from Sparx Systems Enterprise Architect, Sparx Systems provided the facility of a Style sheet so that when applied, the styles defined in the style sheet override the corresponding styles used within the document template(s).

A style sheet is selected when a document is to be generated using either:

  • An artefact selected in the Project Browser such as a package.
  • A Master Document.

The main challenge faced by EA users is the creation of the style sheet, this tutorial provides you with the techniques for the creation and use of a style sheet.


Overview of the Process

The diagram below illustrates the steps involved in the creation of a style sheet.

EA Document Style Sheets - Process Overview

This tutorial focuses on the task of creating a new Style Sheet.


Generating a Document without a Style Sheet

For the purposes of this tutorial I will use a simple example of a single Document Template which:

  • Outputs a Package Name as a heading.
  • Outputs the Diagram(s) contained within that Package.
  • Outputs some selected data for each Element containing in the same Package as the diagram. These data items will be placed in a table.
  • Outputs some plain text.
  • Outputs a list of Realized Requirements for each element.

It is assumed that the reader of this tutorial is familiar with the techniques for creating such a Document Template, but for reference the Template as shown in the Template Editor is shown below:

EA Document Style Sheets - Template Editor

This template was created using the following styles:

Template Content Style Used
Pkg.Name  Heading 2
Table (first column) Table Heading
Table (second column) Table Text Normal
Text Normal
ElemExtRequirement.Name Normal

It is recommended to make a note of the styles used in your Document Template.

The illustration below shows an extract of the report generated when using this template and the following options on the Documentation Generation dialog:

EA Document Style Sheets - Generate Documentation Dialog

EA Document Style Sheets - Customer Shopping Example


Creating a Style Sheet

I now describe the process for creating a style sheet that will provide new definition for all the styles listed in the table above.

You have two choices when creating you own style sheet:

  • Copy and modify a Sparx Systems supplied style sheet.
  • Create a new style sheet from scratch.

This tutorial shows you how to create a style sheet from scratch, but the same process can be used when modifying a copying a Sparx Systems style sheet.

  1. Using the Resources view, right-click in the User Template section and select Create New Template.
  2. Complete the dialog as shown in the example below:
    EA Document Style Sheets - New Document Template Dialog
  3. Click OK and the Template Editor will open.
  4. Right-click in the text area of the Template Editor and select Edit > Edit Style… from the menu:
    EA Document Style Sheets - Edit Style Sheet Dialog
  5. Select the first style you wish to change, for example, Heading 2 from the list labelled Select a style to edit.
  6. Leave the radio button labelled Paragraph Style selected.
  7. Click OK. This closes the dialog and starts a “style recorder”.
  8. Using the Style Toolbar in the Template Editor:
    • Select the corresponding style in the first drop down list.
    • Select you font, size, colour, alignment etc.
  9. When you have finished click anywhere in the Template Editor to see your changes applied add some text, as shown below (Calibri Font, size 14, Bold, Colour Blue, Numbered) :
    EA Document Style Sheets - Template Editor 2
  10. Repeat the process above for all your other styles, and your style sheet should look similar to that below (depending upon what styles you chose during the edit styles process:
    EA Document Style Sheets - Template Editor 3
  11. Notice for the Table Heading, I have set the Cell Colour so as to provide a preview of how tables will appear in my documents.
  12. Save your Style Sheet Template.

Using your New Style Sheet

Now, update your template to set any table cell colour, cell borders and regenerate your document, but this time select the style sheet you just created:

EA Document Style Sheets - Generate Documentation Dialog 2

Below is shown the results of applying your style sheet:

EA Document Style Sheets - Customer Shopping Example - Final


Summary

This short tutorial has provided you with a fool-proof method of creating a Style Sheet in EA so that your generated documents will have a consistent look a feel.

grafx-pdf Mastering EA Document Style Sheets