The complexity of generating bookmarks and hyperlinks in an output document is the dynamicity of both bookmarks and hyperlinks.
The idea is to find a generated or not unique ID that will link source (hyperlink) and target (bookmark) location in the document.
The following example shows how to create dynamic bookmarks and hyperlinks in templates for a UML model containing classes, with references to other classes inside attributes.
Template content |
Output details |
|
Step1 |
Display classes and their attributes and types : <context model=’${project_loc}/Models/TrafficLightManager.uml’ element='TrafficLightManager/LogicalView'/> [c.name/] [for (a:Property|c.ownedAttribute->filter(NamedElement)->sortedBy(name))] -[a.name/]: [a.type.name/] [/for] |
TrafficLight -green fire: GreenFire -orange fire: OrangeFire -red fire: RedFire GreenFire OrangeFire RedFire |
Step2 |
Add a (static) bookmark on the class name : <context model=’${project_loc}/Models/TrafficLightManager.uml’ element='TrafficLightManager/LogicalView'/> [c.name/] Add a bookmark :
Name of the bookmark (must be unique in document) : [for (a:Property|c.ownedAttribute->filter(NamedElement)->sortedBy(name))] -[a.name/]: [a.type.name/] [/for] |
TrafficLight -green fire: GreenFire -orange fire: OrangeFire -red fire: RedFire GreenFire OrangeFire RedFire |
Step3 |
Add dynamicity on the bookmark : Indicate in a dedicated tag on top of document how to generate a dynamic ID at bookmark location to make bookmark become dynamic. What will the bookmark point to : class c How to generate a unique Id for class c : use service getId() from bundle commons. <context model=’${project_loc}/Models/TrafficLightManager.uml’ element='TrafficLightManager/LogicalView'/>
<bookmarks> <gendoc><drop/> [c.name/] Bookmark named :c_name_bookmark [for (a:Property|c.ownedAttribute->filter(NamedElement)->sortedBy(name))] -[a.name/]: [a.type.name/]
[/for] |
TrafficLight -green fire: GreenFire -orange fire: OrangeFire -red fire: RedFire GreenFire OrangeFire RedFire |
Step4 |
Add hyperlinks to the (future) bookmark location : The hyperlink must also be dynamic and point to the future bookmark location, here the generated unique ID for the class. So the hyperlink must no point on c_name_bookmark (it would be replaced by c.getId() and point to current class), but to the id of the property type class: a.type.getId().
<context model=’${project_loc}/Models/TrafficLightManager.uml’
element='TrafficLightManager/LogicalView'/>
[c.name/] Bookmark named : c_name_bookmark [for (a:Property|c.ownedAttribute->filter(NamedElement)->sortedBy(name))] -[a.name/]: [a.type.name/] Add an hyperlink (Insert > Hyperlink … )
[/for] |
TrafficLight -green fire: GreenFire -orange fire: OrangeFire -red fire: RedFire GreenFire OrangeFire RedFire |
Final output |
TrafficLight - green fire: GreenFire - orange fire: OrangeFire - red fire: RedFire |