Derivation of Presentational Views

Extensions to the Style Sheets

In the process of developing the XSLT scripts for this proof of concept we thought about extensibility of the scripts to support the following features:
1. Support of other diagram types and further elements such as interfaces, packages, parameterized classes, association classes, and dependencies (a complete list of all the elements which need to be supported can be found in the UML Notation Guide). This means that the model lookup routines would need to be extended for the new model element types and for the handling routines for these types. Also additional named templates will have to be written for generation of a graphical representation in SVG for these new elements.
2. Support of XLink. In the current implementation a linkage between model and diagram interchange elements is only possible through usage of simple IDRefs. For this reason, only XMI files which contain both model interchange and diagram interchange data can be transformed. This is not acceptable for a final solution. XSLT allows access of different files using the <xsl:for-each> command (<xsl:for-each select="document('other-document.xml')"). For a support of special cases of XLinks where only a document and an IDRef is used, an imple-mentation could employ the string functions of XPath to extract link information. A general solution of XLink should be possible with the usage of a XLink library by an XSLT extension. All templates which need the XLink support can be found in util_modellookup.xsl.
3. Last but not least there is a need for support of transformation for files which contain more than one diagram-which is the most common case.

To accomplish this, one of the following solutions might be implemented:
· A parameterized set of scripts which still only extract one diagram is a viable alternative. An external application controls the calls of these scripts for the different diagrams. One parameter selects the extracted diagram.
· With the use of XSLT extensions, a generation of several output files can be implemented. With this feature an SVG file for each diagram could be generated.
· A solution could be a dynamic SVG which contains all diagrams and a user interface to switch between the diagrams in the SVG browser.

Transformation to Other Notations

For the proof of concept we implemented only the transformation to one graphical representation as defined in UML Notation Guide. Generally any notation is possible as long as no renderer algorithm is required. This allows modeling tools to provide XSLT scripts which generate SVG with their own notation. For example, some tools draw shadows for classes and objects or make use of colors.

For a notation where position of graphical elements change, a renderer is needed. This renderer might be connected to the stylesheets via XSLT extensions. However, in this case, XSLT might not be the best solution.

With the following example we wish to show how simple a change to the scripts for a different notation might be. In the example given we change the representation of a class element.

For the generation of the class element the script build_class is responsible. We extracted the lines of interest from this stylesheet:


<g style="fill:none;stroke:black;stroke-width:1">
<rect height="{$height}" width="{$width}" style="fill:white"/>
<xsl:if test="$draw_attributes">

<line y1="{$Attrib_PartStart}"y2="{$Attrib_PartStart}" x2="{$width}" style="fill:none;stroke:black;stroke-
width:1"/>
</xsl:if>
<xsl:if test="$draw_operations">

<line y1="{$Operation_PartStart}" y2="{$Operation_PartStart}" x2="{$width}"
style="fill:none;stroke:black;stroke-width:1"/>
</xsl:if>
</g>

With this code, a class looks the way it is defined in the UML Notation Guide. A solid-outline rectangle with three compartments separated by horizontal lines will be viewed in an SVG browser.

With only a small change in this code, a class with shadow and round edges can be viewed.


<g style="fill:none;stroke:black;stroke-width:1">
<rect x="2" y="2" rx="4" ry="4" height="{$height}" width="{$width}" style="fill:grey"/>
<rect rx="4" ry="4" height="{$height}" width="{$width}" style="fill:white"/>
<xsl:if test="$draw_attributes">
<line y1="{$Attrib_PartStart}" y2="{$Attrib_PartStart}" x2="{$width}" style="fill:none;stroke:black;stroke-
width:1"/>
</xsl:if>
<xsl:if test="$draw_operations">
<line y1="{$Operation_PartStart}" y2="{$Operation_PartStart}" x2="{$width}" style="fill:none;stroke:black;stroke-
width:1"/>
</xsl:if>
</g>