Question & Answer
Question
This technote describes how you can write a BIRT report that creates a Table where the Rich Text Format Documentation of each Named Model element is displayed, side by side with the Element's name.
Cause
There is no field of a NamedModel element called simply Documentation.
1. The Documentation of an element can be retrieved with the following expression:
getElementsWithStereotype(ownedComment,'Default::Documentation')[1]/@body
because the Documentation is the body attribute of the first ownedComment stereotyped as:
Default::Documentation
2. Starting with version 7.0.5, the Documentation can be stored as rich text in the model.
To be able to display the rich text correctly in the report, you must bind the Documentation column to:
Dynamic Text Widget.
Answer
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
|---|
Create the Model
1. Create a new Modeling project from File > New > Model project:
- DemoDocumentatonProject
- DemoDocumentationModel
| This is a Model to document reporting on Rich Text Documentation |
4. Using the Rich controls, center the text and set the format to Heading 1
5. Right click on the Model in Project Explorer and choose Add UML->Actor
5. Add the text
| This is the documentation of an Actor |
6. Using the Rich controls, set the format to Heading 2 and the color to red
7. Save the Model
Create the Report
1. Click on the Report Explorer fast View
or
Open the Report Explorer with Window>Show View>Other>Reporting > Report Explorer
(you can also type Report Explorer in the Show View dialog to find the View)

2. Right click on UML Model and choose: New Report

3. Select the Blank UML Model Report template

4. Enter the display name for the Report: Documentation UML Model Report

5. Enter the file name for the report: AllDocumentationUMLModelReport.rptdesign
and a location where it will always be available

6. The report is added to the Report Explorer

7. Double click on the newly added report: it will open in the Report Design Perspective
8. In the Data Explorer View, right click on Data Sources > Main Model and choose Edit

9. Delete the URL to the Model Kitchen.emx and add the URL to the UML file DemoDocumentationModel.emx created above

10. Right click on the DataSet All Named Elements and choose: Edit

11. Review the contents of Table Mapping:
UML Structure = Metamodel
XPath Expression = oclQuery(//*,"self.oclIsKindOf(uml::NamedElement)")
Result Type= uml.NamedElement

12. Review the contents of Column Mapping for NamedElement where the documentation has the XPath:
getElementsWithStereotype(ownedComment,'Default::Documentation')[1]/@body

13. Right click on the surface of the Report
Insert>Data Table
Number of columns: 2
Number of details: 1
Data Set: All Named Elements

14. Review the result:

15. From the palette, drag and drop a Label on the first column of header row and set the Text to Element Name
16. Right click on the second column of header row, select Insert>Label and set the Text to Documentation
17. From the Data Explorer, drag and drop the column qualifiedName of All Named Elements onto the first column of detail row
18. Select the second column of detail row, right click and insert Dynamic Text (so that the rich text contained in the model is preserved).
This action opens the Expression Builder.

20. Bind the column documentation of All Named Elements to the Dynamic Text by double clicking on the Category: Available Column Bindings, then on the only available Sub-category and finally on the column itself, so that the content of the Expression Builder becomes:
row["documentation"]

21. To improve the layout, select the first column of the table, right click and choose: Style >New Style…

22. Define the Box parameters adding 20 points for Left and Right Padding and 20 points for Left and Right Margin

23. Set the Border Style as Solid with width Thin on all sides

24. Right click on the second column and select Style>Apply Style>New Style
25. Save the report
Run the Report
You can view the results by doing one of the following:
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21294412