<?xml version="1.0" encoding="UTF-8"?>
<!--
	Document: activityDiagram2svg_standalone.xsl
	Author: Dirk Boicourt

	TODO:
-->

<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:UML="org.omg.xmi.namespace.UML" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output media-type="image/svg+xml" method="xml"  indent="yes"/>

	<xsl:template match="text()"/>

	<!--
		This is the ID of the ClassDiagram to transform as a Parameter. If the Parameter is empty, the first ClassDiagram in the XMI-File is transformed
	-->   	
   	<xsl:param name="diagramID" /> 

	<!-- ********************************************************
	        ** Kopf des SVG Dokuments. Mit der Groessen angabe **
	        ******************************************************** -->
	<xsl:template match="XMI/XMI.content/UML:ActivityGraph">
		
		<!-- Which Diagram to transform? -->
		<xsl:variable name="DiagramID">
			<xsl:choose>
				<xsl:when test="$diagramID"><xsl:value-of select="$diagramID"/></xsl:when>								
				<!-- The first ClassDiagram found in XMI-File -->
				<xsl:otherwise>
				   	<xsl:value-of select="//UML:Diagram[position()=1][child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='ActivityDiagram']]/attribute::xmi.id"/>
				</xsl:otherwise>
			</xsl:choose>			
		</xsl:variable>
		
	   	<!--
	   		Sometime the x-Pos of the most left Objects (Classes, Associations and so on) is negative. If this happens, we add the negative value to every other x-Pos, so that the diagram moves right, an nothing will be cut.
	   		The Reason is because the Position in Diagram are relative to other Diagrams. But in SVG the top right point ist 0,0 . No negative Values are allowed.
	   		The Same for the y-Pos of some Objects 
	   	-->
		<xsl:variable name="shift_x">	
			<xsl:call-template name="getGlobal_x">
				<xsl:with-param name="DiagramID" select="$DiagramID" />
			</xsl:call-template>			
		</xsl:variable>
	
		<xsl:variable name="shift_y">			
			<xsl:call-template name="getGlobal_y">
				<xsl:with-param name="DiagramID" select="$DiagramID" />
			</xsl:call-template>			
		</xsl:variable>	
	
		<!-- Auswahl der Breite -->
		<xsl:variable name="width">
			<xsl:call-template name="getWidth">			
				<xsl:with-param name="DiagramID" select="$DiagramID" />
			</xsl:call-template>
		</xsl:variable>
	
		<!-- Berechnen der Höhe -->
		<xsl:variable name="height">
			<xsl:call-template name="getHeight">
				<xsl:with-param name="DiagramID" select="$DiagramID" />
			</xsl:call-template>			
		</xsl:variable>
		
		<svg>
			<xsl:attribute name="width"><xsl:value-of select="$width + $shift_x + 20"/></xsl:attribute>
			<xsl:attribute name="height"><xsl:value-of select="$height + $shift_y + 20"/></xsl:attribute>		

			<defs>
				<!-- transparente Pfeilspitze, nur mit den Pfeilkanten -->
				<marker id="dep_arrowhead" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="11" markerHeight="11" orient="auto" fill="none">
					<path stroke="black" d="M 0 0 L 10 5 L 0 10"/>
				</marker>
			</defs>

			<xsl:apply-templates>
				<xsl:with-param name="DiagramID" select="$DiagramID" />
				<xsl:with-param name="shift_x" select="$shift_x" />
				<xsl:with-param name="shift_y" select="$shift_y" />	
			</xsl:apply-templates>			

		</svg>
	</xsl:template>

	<!--**************************************************
	       ** Darstellung der Action States **
	       ****************************************************-->
	<xsl:template match="UML:ActionState">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />

		<xsl:variable name="ID" select="@xmi.id"/>
		<xsl:variable name="name" select="UML:State.entry/UML:CallAction/UML:Action.script/UML:ActionExpression/@body"/>

		<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1] + $shift_x"/>
		<xsl:variable name="pos_y" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=2] + $shift_y"/>
		<xsl:variable name="width" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1]"/>
		<xsl:variable name="height" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=2]"/>

		<xsl:if test="$pos_x">

			<xsl:comment>**************** Action State <xsl:value-of select="$name"/> ****************</xsl:comment>
			<!-- Action State -->
			<rect x="{$pos_x}" y="{$pos_y}" width="{$width}" height="{$height}" rx="5" ry="8" fill="none" stroke="black"/>
			
			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:ActionState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Expression']]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="namePos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:ActionState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Expression']]/UML:GraphElement.position/XMI.field[position()=2]"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x + 21"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 30"/></xsl:attribute>
	
				<xsl:attribute name="style">
					<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
				</xsl:attribute>
	
				<tspan>
					<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x + 21"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 30"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>

			<!-- ID of GraphNode -->
			<xsl:variable name="graphNodeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ActionState[attribute::xmi.idref=$ID]]/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
			<xsl:variable name="stereoPos_x" select="//UML:GraphNode[descendant::UML:ActionState[attribute::xmi.idref=$ID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="stereoPos_y" select="//UML:GraphNode[descendant::UML:ActionState[attribute::xmi.idref=$ID]]/UML:GraphElement.position/XMI.field[position()=2]" />
			
			<!-- stereotype -->
			<xsl:apply-templates select="UML:ModelElement.stereotype">
				<xsl:with-param name="object_x" select="$stereoPos_x"/>
				<xsl:with-param name="object_y" select="$stereoPos_y"/>
				<xsl:with-param name="package_x" select="$shift_x"/>
				<xsl:with-param name="package_y" select="$shift_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>

		</xsl:if>

	</xsl:template>


	<!--**************************************************
	       ** Darstellung der Object Flow States **
	       ****************************************************-->
	<xsl:template match="UML:ObjectFlowState">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />

		<xsl:variable name="ID" select="@xmi.id"/>
		<xsl:variable name="name" select="@name"/>

		<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1] + $shift_x"/>
		<xsl:variable name="pos_y" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=2] + $shift_y"/>
		<xsl:variable name="width" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1]"/>
		<xsl:variable name="height" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=2]"/>

		<xsl:if test="$pos_x">

			<xsl:comment>**************** Object Flow State <xsl:value-of select="$name"/> ****************</xsl:comment>

			<!-- Object Flow State -->
			<rect x="{$pos_x}" y="{$pos_y}" width="{$width}" height="{$height}" fill="none" stroke="black"/>

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:ObjectFlowState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="namePos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:ObjectFlowState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x + 3"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 15"/></xsl:attribute>
	
				<xsl:attribute name="style">
					<xsl:text>font-size:11px; font-weight:normal; text-decoration:underline</xsl:text>
				</xsl:attribute>
	
				<tspan>
					<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x + 3"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 15"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>

			<xsl:if test="./UML:ObjectFlowState.type/UML:ClassifierInState/@xmi.idref">
				<xsl:variable name="classifier" select="./UML:ObjectFlowState.type/UML:ClassifierInState/@xmi.idref"/>
				<xsl:variable name="classifierName" select="//UML:Model/*/UML:ClassifierInState[attribute::xmi.id=$classifier]/@name"/>
				<xsl:variable name="typeSep_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ObjectFlowState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='NameCompartment']]/UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='TypeSeparator']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="typeSep_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ObjectFlowState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='NameCompartment']]/UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='TypeSeparator']]/UML:GraphElement.position/XMI.field[position()=2]" />
				<xsl:variable name="typeName_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ObjectFlowState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='NameCompartment']]/UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.contained/*/*/*[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="typeName_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ObjectFlowState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='NameCompartment']]/UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.contained/*/*/*[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]" />

				<text>
					<xsl:attribute name="x"><xsl:value-of select="$typeSep_x + $namePos_x + $pos_x + 3"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$typeSep_y + $namePos_y + $pos_y + 15"/></xsl:attribute>
		
					<xsl:attribute name="style">
						<xsl:text>font-size:11px; font-weight:normal; text-decoration:underline</xsl:text>
					</xsl:attribute>
		
					<tspan>
						<xsl:attribute name="x"><xsl:value-of select="$typeSep_x + $namePos_x + $pos_x + 3"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$typeSep_y + $namePos_y + $pos_y + 15"/></xsl:attribute>
						:<xsl:value-of select="$classifierName"/>
					</tspan>
				</text>
			</xsl:if>

		</xsl:if>

	</xsl:template>


	<!--**************************************************
	       ** Darstellung der Final States **
	       ****************************************************-->
	<xsl:template match="UML:FinalState">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />

		<xsl:variable name="ID" select="@xmi.id"/>
		<xsl:variable name="name" select="@name"/>

		<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1] + $shift_x"/>
		<xsl:variable name="pos_y" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=2] + $shift_y"/>
		<xsl:variable name="radius" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1]"/>

		<xsl:if test="$pos_x">

			<xsl:comment>**************** Final State <xsl:value-of select="$name"/> ****************</xsl:comment>

			<!-- Final State -->
			<circle cx="{$pos_x + $radius div 2}" cy="{$pos_y + $radius div 2}" r="{$radius div 2}" fill="none" stroke="black"/>
			<circle cx="{$pos_x + $radius div 2}" cy="{$pos_y + $radius div 2}" r="{($radius - ($radius div 3)) div 2}" fill="black" stroke="black"/>

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:FinalState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="namePos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:FinalState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12"/></xsl:attribute>
	
				<xsl:attribute name="style">
					<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
				</xsl:attribute>
	
				<tspan>
					<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>

		</xsl:if>

	</xsl:template>


	<!--**************************************************
	       ** Darstellung der Synch States **
	       ****************************************************-->
	<xsl:template match="UML:SynchState">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />

		<xsl:variable name="ID" select="@xmi.id"/>
		<xsl:variable name="name" select="@name"/>

		<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1] + $shift_x"/>
		<xsl:variable name="pos_y" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=2] + $shift_y"/>
		<xsl:variable name="radius" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1]"/>

		<xsl:if test="$pos_x">

			<xsl:comment>**************** Sync State <xsl:value-of select="$name"/> ****************</xsl:comment>

			<!-- Sync State -->
			<circle cx="{$pos_x + $radius div 2}" cy="{$pos_y + $radius div 2}" r="{$radius div 2}" fill="none" stroke="black"/>
			<text style="text-decoration:none;font-size:20px">
				<xsl:attribute name="x"><xsl:value-of select="$pos_x + $radius div 3"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$pos_y + $radius"/></xsl:attribute>
				<xsl:text>*</xsl:text>
			</text>

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:SynchState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="namePos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:SynchState[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12"/></xsl:attribute>
	
				<xsl:attribute name="style">
					<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
				</xsl:attribute>
	
				<tspan>
					<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>

		</xsl:if>

	</xsl:template>


	<!--**************************************************
	       ** Darstellung der Pseudo States **
	       ****************************************************-->
	<xsl:template match="UML:Pseudostate">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />

		<xsl:variable name="ID" select="@xmi.id"/>
		<xsl:variable name="name" select="@name"/>

		<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1] + $shift_x"/>
		<xsl:variable name="pos_y" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=2] + $shift_y"/>
		<xsl:variable name="size1" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=1]"/>
		<xsl:variable name="size2" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$ID]]/XMI.field[position()=2]"/>

		<xsl:if test="$pos_x">

			<xsl:comment>**************** Pseudo State <xsl:value-of select="$name"/> ****************</xsl:comment>

			<!-- Pseudo State -->
			<xsl:choose>
				<xsl:when test="@kind = 'initial'">
					<circle cx="{$pos_x + $size1 div 2}" cy="{$pos_y + $size1 div 2}" r="{$size1 div 2}" fill="black" stroke="black"/>
				</xsl:when>
	
				<xsl:when test="@kind = 'junction'">
					<xsl:variable name="poly_x" select="$pos_x + $size1 div 2"/>
					<xsl:variable name="poly_y" select="$pos_y"/>
					<polygon points="{$poly_x},{$poly_y} {$poly_x - ($size1 div 2)},{$poly_y + ($size1 div 2)} {$poly_x},{$poly_y + $size1} {$poly_x + ($size1 div 2)},{$poly_y + ($size1 div 2)} {$poly_x},{$poly_y}" fill="none" stroke="black"/>
				</xsl:when>
	
				<xsl:when test="@kind = 'join'">
					<rect x="{$pos_x}" y="{$pos_y}" width="{$size1}" height="{$size2}" fill="black" stroke="black"/>
				</xsl:when>
	
				<xsl:when test="@kind = 'fork'">
					<rect x="{$pos_x}" y="{$pos_y}" width="{$size1}" height="{$size2}" fill="black" stroke="black"/>
				</xsl:when>
			</xsl:choose>

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:Pseudostate[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="namePos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:Pseudostate[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12"/></xsl:attribute>
	
				<xsl:attribute name="style">
					<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
				</xsl:attribute>
	
				<tspan>
					<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>

		</xsl:if>

	</xsl:template>


	<!--**************************************************
	       ** Darstellung der Transitions **
	       ****************************************************-->
	<xsl:template match="UML:Transition">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />

		<xsl:variable name="ID" select="@xmi.id" />
		<xsl:variable name="name" select="@name"/>
		<xsl:variable name="source" select="./UML:Transition.source/UML:ObjectFlowState/@xmi.idref"/>
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->
		<xsl:variable name="control" select="//UML:GraphEdge[descendant::UML:Transition[attribute::xmi.idref=$ID]]/UML:GraphEdge.waypoints/XMI.field" />
		
		<xsl:if test="$control">

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphEdge[child::UML:GraphElement.semanticModel/*/*/UML:Transition[attribute::xmi.idref=$ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x"/>
			<xsl:variable name="namePos_y" select="//UML:GraphEdge[child::UML:GraphElement.semanticModel/*/*/UML:Transition[attribute::xmi.idref=$ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y"/>

			<xsl:comment>**************** Transition <xsl:value-of select="$name"/> ****************</xsl:comment>
			<xsl:variable name="path">
				<xsl:call-template name="buildPath">
					<xsl:with-param name="waypoints" select="//UML:GraphEdge[descendant::UML:Transition[attribute::xmi.idref=$ID]]/UML:GraphEdge.waypoints/XMI.field" />
					<xsl:with-param name="pos" select="count(//UML:GraphEdge[descendant::UML:Transition[attribute::xmi.idref=$ID]]/UML:GraphEdge.waypoints/XMI.field) -1" />
					<xsl:with-param name="package_x" select="$shift_x" />
					<xsl:with-param name="package_y" select="$shift_y" />
				</xsl:call-template> 
			</xsl:variable>

			<!-- Der Pfeil -->    
			<path stroke="black" fill="none">
				<xsl:attribute name="d">M<xsl:value-of select="substring-after($path,'L')"/></xsl:attribute>
				<xsl:attribute name="marker-end">url(#dep_arrowhead)</xsl:attribute>
				<xsl:if test="$source"><xsl:attribute name="stroke-dasharray">5,5</xsl:attribute></xsl:if>
			</path>         

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y"/></xsl:attribute>
	
				<xsl:attribute name="style">
					<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
				</xsl:attribute>
	
				<tspan>
					<xsl:attribute name="x"><xsl:value-of select="$namePos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>

			<!-- x und y Position der Description -->
			<xsl:variable name="descPos_x" select="//UML:GraphEdge[child::UML:GraphElement.semanticModel//UML:Transition[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='TransitionDescription']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x"/>
			<xsl:variable name="descPos_y" select="//UML:GraphEdge[child::UML:GraphElement.semanticModel//UML:Transition[attribute::xmi.idref=$ID]]/UML:GraphElement.contained//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='TransitionDescription']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y"/>

			<xsl:if test="./UML:Transition.guard">
				<xsl:variable name="guardID" select="./UML:Transition.guard/UML:Guard/@xmi.id" />
				<xsl:variable name="guardName" select="./UML:Transition.guard/UML:Guard/@name" />

				<!-- x und y Position des Namens -->
				<xsl:variable name="guardNamePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Guard[attribute::xmi.idref=$guardID]]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="guardNamePos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Guard[attribute::xmi.idref=$guardID]]/UML:GraphElement.position/XMI.field[position()=2]" />

				<text>
					<xsl:attribute name="x"><xsl:value-of select="$descPos_x + $guardNamePos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$descPos_y + $guardNamePos_y + 8"/></xsl:attribute>
		
					<xsl:attribute name="style">
						<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
					</xsl:attribute>
		
					<tspan>
						<xsl:attribute name="x"><xsl:value-of select="$descPos_x + $guardNamePos_x"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$descPos_y + $guardNamePos_y + 8"/></xsl:attribute>
						[ ]
					</tspan>
				</text>
			</xsl:if>

			<xsl:if test="./UML:Transition.effect">
				<xsl:variable name="effectID" select="./UML:Transition.effect/UML:CallAction/@xmi.id" />
				<xsl:variable name="effectName" select="./UML:Transition.effect/UML:CallAction/@name" />

				<!-- x und y Position des Namens -->
				<xsl:variable name="effectNamePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:CallAction[attribute::xmi.idref=$effectID]]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="effectNamePos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:CallAction[attribute::xmi.idref=$effectID]]/UML:GraphElement.position/XMI.field[position()=2]" />

				<text>
					<xsl:attribute name="x"><xsl:value-of select="$descPos_x + $effectNamePos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$descPos_y + $effectNamePos_y + 8"/></xsl:attribute>
		
					<xsl:attribute name="style">
						<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
					</xsl:attribute>
		
					<tspan>
						<xsl:attribute name="x"><xsl:value-of select="$descPos_x + $effectNamePos_x"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$descPos_y + $effectNamePos_y + 8"/></xsl:attribute>
						/
					</tspan>
				</text>
			</xsl:if>

			<xsl:if test="./UML:Transition.trigger">
				<xsl:variable name="triggerID" select="./UML:Transition.trigger/UML:CallEvent/@xmi.idref" />
				<xsl:variable name="triggerName" select="/XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:CallEvent[attribute::xmi.id=$triggerID]/@name" />

				<!-- x und y Position des Namens -->
				<xsl:variable name="triggerNamePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:CallEvent[attribute::xmi.idref=$triggerID]]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="triggerNamePos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:CallEvent[attribute::xmi.idref=$triggerID]]/UML:GraphElement.position/XMI.field[position()=2]" />

				<text>
					<xsl:attribute name="x"><xsl:value-of select="$descPos_x + $triggerNamePos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$descPos_y + $triggerNamePos_y + 8"/></xsl:attribute>
		
					<xsl:attribute name="style">
						<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
					</xsl:attribute>
		
					<tspan>
						<xsl:attribute name="x"><xsl:value-of select="$descPos_x + $triggerNamePos_x"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$descPos_y + $triggerNamePos_y + 8"/></xsl:attribute>
						<xsl:value-of select="$triggerName"/>
					</tspan>
				</text>
			</xsl:if>

		</xsl:if>

	</xsl:template>
	
	<xsl:template name="getGlobal_x">
		<xsl:param name="DiagramID" />
		
		<xsl:variable name="temp">
			<xsl:for-each select="//UML:Diagram[attribute::xmi.id=$DiagramID]/UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.position">
			      <xsl:sort select="XMI.field[1]" data-type="number" order="ascending" />
			      <xsl:if test="position() = 1">
			         <xsl:value-of select="XMI.field[1]" />
			      </xsl:if>
			</xsl:for-each>
		</xsl:variable>

		<xsl:variable name="temp_2">
			<xsl:for-each select="//UML:Diagram[attribute::xmi.id=$DiagramID]/UML:GraphElement.contained/UML:GraphEdge/UML:GraphEdge.waypoints/XMI.field">
			      <xsl:sort select="XMI.field[1]" data-type="number" order="ascending" />
			      <xsl:if test="position() = 1">
			         <xsl:value-of select="XMI.field[1]" />
			      </xsl:if>
			</xsl:for-each>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="number($temp) &lt; 0">
				<xsl:if test="number($temp) &lt; number($temp_2)"><xsl:value-of select="($temp * -1) + 40"/></xsl:if>
				<xsl:if test="number($temp_2) &lt; number($temp)"><xsl:value-of select="($temp_2 * -1) + 40"/></xsl:if>
			</xsl:when>
			<xsl:when test="number($temp_2) &lt; 0">
				<xsl:if test="number($temp) &lt; number($temp_2)"><xsl:value-of select="($temp * -1) + 40"/></xsl:if>
				<xsl:if test="number($temp_2) &lt; number($temp)"><xsl:value-of select="($temp_2 * -1) + 40"/></xsl:if>				
			</xsl:when>			
			<xsl:otherwise>0</xsl:otherwise>
		</xsl:choose>	
	</xsl:template>
	
	<xsl:template name="getGlobal_y">
		<xsl:param name="DiagramID" />

		<xsl:variable name="temp">
			<xsl:for-each select="//UML:Diagram[attribute::xmi.id=$DiagramID]/UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.position">
			      <xsl:sort select="XMI.field[2]" data-type="number" order="ascending" />
			      <xsl:if test="position() = 1">
			      	<xsl:value-of select="XMI.field[2]" />
			      </xsl:if>
			   </xsl:for-each>		
		</xsl:variable>

		<xsl:variable name="temp_2">
			<xsl:for-each select="//UML:Diagram[attribute::xmi.id=$DiagramID]/UML:GraphElement.contained/UML:GraphEdge/UML:GraphEdge.waypoints/XMI.field">
			      <xsl:sort select="XMI.field[2]" data-type="number" order="ascending" />
			      <xsl:if test="position() = 1">
			         <xsl:value-of select="XMI.field[2]" />
			      </xsl:if>
			   </xsl:for-each>						
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="number($temp) &lt; 0">
				<xsl:if test="number($temp) &lt; number($temp_2)"><xsl:value-of select="(number($temp) * -1) + 40"/></xsl:if>
				<xsl:if test="number($temp_2) &lt; number($temp)"><xsl:value-of select="(number($temp_2) * -1) + 40"/></xsl:if>
			</xsl:when>
			<xsl:when test="number($temp_2) &lt; 0">
				<xsl:if test="number($temp) &lt; number($temp_2)"><xsl:value-of select="(number($temp) * -1) + 40"/></xsl:if>
				<xsl:if test="number($temp_2) &lt; number($temp)"><xsl:value-of select="(number($temp_2) * -1) + 40"/></xsl:if>				
			</xsl:when>			
			<xsl:otherwise>0</xsl:otherwise>
		</xsl:choose>	
	</xsl:template>
	
	<xsl:template name="getWert_1">
		<xsl:param name="nodes" />
		
		<xsl:choose>
			<xsl:when test="$nodes">
				<xsl:variable name="wert_1">
					<xsl:value-of select="$nodes[position()=last()]/UML:GraphElement.position/XMI.field[1]"/>
				</xsl:variable>
				<xsl:variable name="wert_2">
					<xsl:value-of select="$nodes[position()=last()]/UML:GraphNode.size/XMI.field[1]"/>
				</xsl:variable>
				<xsl:variable name="pruef"><xsl:value-of select="$wert_1 + $wert_2"/></xsl:variable>
	
				<xsl:variable name="large">
					<xsl:call-template name="getWert_1">
						<xsl:with-param name="nodes" select="$nodes[position()!=last()]" />
					</xsl:call-template>
				</xsl:variable>
	
				<xsl:choose>
					<xsl:when test="number($pruef) &gt; number($large)">
						<xsl:value-of select="number($pruef)"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="number($large)"/>
					</xsl:otherwise>
				</xsl:choose>			
			</xsl:when>
			<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>			
		</xsl:choose>
	</xsl:template>

	<xsl:template name="getWert_2">
		<xsl:param name="nodes" />
		
		<xsl:choose>
			<xsl:when test="$nodes">
				<xsl:variable name="wert_1">
					<xsl:value-of select="$nodes[position()=last()]/UML:GraphElement.position/XMI.field[2]"/>
				</xsl:variable>
				<xsl:variable name="wert_2">
					<xsl:value-of select="$nodes[position()=last()]/UML:GraphNode.size/XMI.field[2]"/>
				</xsl:variable>
				<xsl:variable name="pruef"><xsl:value-of select="number($wert_1) + number($wert_2)"/></xsl:variable>
	
				<xsl:variable name="large">
					<xsl:call-template name="getWert_2">
						<xsl:with-param name="nodes" select="$nodes[position()!=last()]" />
					</xsl:call-template>			
				</xsl:variable>
	
				<xsl:choose>
					<xsl:when test="number($pruef) &gt; number($large)">
						<xsl:value-of select="$pruef"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$large"/>
					</xsl:otherwise>
				</xsl:choose>			
			</xsl:when>
			<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="getWidth">
		<xsl:param name="DiagramID" />
		
		<!-- welcher Punkt der Klassen hat den höchsten X-Wert -->
		<xsl:variable name="temp">
			<xsl:call-template name="getWert_1">
				<xsl:with-param name="nodes" select="//UML:Diagram[attribute::xmi.id=$DiagramID]/UML:GraphElement.contained/UML:GraphNode" />
			</xsl:call-template>			  
		</xsl:variable>

		<!-- Welcher Wegpunkt hat den höchsten X-Wert -->
 		<xsl:variable name="temp_2">
			<xsl:for-each select="//UML:Diagram[attribute::xmi.id=$DiagramID]/UML:GraphElement.contained/UML:GraphEdge/UML:GraphEdge.waypoints/XMI.field">
				<xsl:sort select="XMI.field[1]" data-type="number" order="descending" />
				<xsl:if test="position() = 1">
					 <xsl:value-of select="XMI.field[1]" />
				 </xsl:if>
			 </xsl:for-each>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="number($temp_2)">
				<xsl:choose>
			 		<xsl:when test="number($temp) &gt; number($temp_2)"><xsl:value-of select="number($temp) + 20"/></xsl:when>
					<xsl:otherwise><xsl:value-of select="number($temp_2) + 20"/></xsl:otherwise>
				</xsl:choose>			
			</xsl:when>
			<xsl:otherwise><xsl:value-of select="number($temp)"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template name="getHeight">
		<xsl:param name="DiagramID" />
		
		<xsl:variable name="temp">
			<xsl:call-template name="getWert_2">
				<xsl:with-param name="nodes" select="//UML:Diagram[attribute::xmi.id=$DiagramID]/UML:GraphElement.contained/UML:GraphNode" />			   	
			</xsl:call-template>			  			
		</xsl:variable>
		
		<!-- welcher Waypoint hat den höchsten y-Wert -->
		<xsl:variable name="temp_2">
			<xsl:for-each select="//UML:Diagram[attribute::xmi.id=$DiagramID]/UML:GraphElement.contained/UML:GraphEdge/UML:GraphEdge.waypoints/XMI.field">
			      <xsl:sort select="XMI.field[2]" data-type="number" order="descending" />
			      <xsl:if test="position() = 1">
			         <xsl:value-of select="XMI.field[2]" />
			      </xsl:if>
			   </xsl:for-each>
		</xsl:variable>
		
		<!-- Auswahl der Höhe -->
		<xsl:choose>
			<xsl:when test="number($temp_2)">
				<xsl:choose>
			 		<xsl:when test="number($temp) &gt; number($temp_2)"><xsl:value-of select="number($temp) + 20"/></xsl:when>
					<xsl:otherwise><xsl:value-of select="number($temp_2) + 20"/></xsl:otherwise>
				</xsl:choose>			
			</xsl:when>
			<xsl:otherwise><xsl:value-of select="number($temp)"/></xsl:otherwise>
		</xsl:choose>

	</xsl:template>

	 <!-- The Stereotypes with Separator, Start and End -->
	<xsl:template match="UML:ModelElement.stereotype">
		<xsl:param name="object_x"/>
		<xsl:param name="object_y"/>
		<xsl:param name="package_x"/>
		<xsl:param name="package_y"/>
		<xsl:param name="graphNodeID"/>
		
		<xsl:variable name="stereotypeCompartment_x" select="//UML:GraphNode[attribute::xmi.id=$graphNodeID]/UML:GraphElement.position/XMI.field[position()=1]" />
		<xsl:variable name="stereotypeCompartment_y" select="//UML:GraphNode[attribute::xmi.id=$graphNodeID]/UML:GraphElement.position/XMI.field[position()=2]" />
		
		<xsl:for-each select="//UML:GraphNode[attribute::xmi.id=$graphNodeID]/UML:GraphElement.contained/UML:GraphNode">
			<xsl:variable name="stereotypeElement_x" select="UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="stereotypeElement_y" select="UML:GraphElement.position/XMI.field[position()=2]" />

			<xsl:variable name="stereotypeElement_typeInfo" select="UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement/attribute::typeInfo" />
			<xsl:choose>
				<xsl:when test="$stereotypeElement_typeInfo = 'StereotypeStart'">
					<text x="{$object_x +$package_x + $stereotypeElement_x + $stereotypeCompartment_x + 12}" y="{$object_y +12 + $package_y + $stereotypeElement_y + $stereotypeCompartment_y}" font-weight="normal" style="font-size:11px">
						«
					</text>
				</xsl:when>
				<xsl:when test="$stereotypeElement_typeInfo = 'StereotypeEnd'">
					<text x="{$object_x +$package_x + $stereotypeElement_x  + $stereotypeCompartment_x}" y="{$object_y +12 + $package_y + $stereotypeElement_y + $stereotypeCompartment_y}" font-weight="normal" style="font-size:11px">
						»
					</text>
				</xsl:when>
				<xsl:when test="$stereotypeElement_typeInfo = 'StereotypeSeparator'">
					<text x="{$object_x +$package_x + $stereotypeElement_x + $stereotypeCompartment_x}" y="{$object_y +12 + $package_y + $stereotypeElement_y + $stereotypeCompartment_y}" font-weight="normal" style="font-size:11px">
						,
					</text>
				</xsl:when>
			</xsl:choose>
			
			<xsl:variable name="stereotypeID" select="UML:GraphElement.semanticModel/UML:Uml1SemanticModelBridge/UML:Uml1SemanticModelBridge.element/UML:Stereotype/attribute::xmi.idref" />

			<xsl:if test="$stereotypeID != '' ">
				<text x="{$object_x +$package_x + $stereotypeElement_x + $stereotypeCompartment_x}" y="{$object_y  + $stereotypeElement_y +12 + $package_y + $stereotypeCompartment_y}" font-weight="normal" style="font-size:11px">
					<xsl:if test="//UML:Stereotype[attribute::xmi.id=$stereotypeID]/attribute::isAbstract = 'true' ">
						<xsl:attribute name="font-style">oblique</xsl:attribute>
					</xsl:if>                    
					<xsl:if test="//UML:Stereotype[attribute::xmi.id=$stereotypeID]/attribute::name = '' "><xsl:text>anonym</xsl:text></xsl:if>
					<xsl:value-of select="//UML:Stereotype[attribute::xmi.id=$stereotypeID]/attribute::name"/>
				</text>            	
			</xsl:if>
		</xsl:for-each>
	</xsl:template>
	
	<!-- Baut den Pfad aus den Waypoints auf -->
	<xsl:template name="buildPath">
		<xsl:param name="waypoints" />
		<xsl:param name="pos" />
		<xsl:param name="package_x" />
		<xsl:param name="package_y" />
		<xsl:choose>
			<xsl:when test="$waypoints">
				<xsl:variable name="first" select="$waypoints[position()=last()]" />		
				<xsl:call-template name="buildPath">
					<xsl:with-param name="waypoints" select="$waypoints[position()!=last()]" />
					<xsl:with-param name="pos" select="$pos - 1" />
					<xsl:with-param name="package_x" select="$package_x" />
					<xsl:with-param name="package_y" select="$package_y" />										
				</xsl:call-template>
				<xsl:if test="($pos mod 3)=0">
					<xsl:text>L</xsl:text>			
					<xsl:value-of select="$first/XMI.field[position()=1] + $package_x"/><xsl:text> </xsl:text><xsl:value-of select="$first/XMI.field[position()=2]  + $package_y"/><xsl:text> </xsl:text>
				</xsl:if>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<!-- Schreibt das richtige Zeichen der jeweiligen Sichtbarkeit auf -->
	<xsl:template name="getVisibility">
		<xsl:param name="visibility" />
		<xsl:choose>
			<xsl:when test="$visibility = 'public' ">+</xsl:when>
			<xsl:when test="$visibility = 'protected' ">#</xsl:when>
			<xsl:when test="$visibility = 'package' ">~</xsl:when>
			<xsl:when test="$visibility = 'private' ">-</xsl:when>                    
		</xsl:choose>                    
	</xsl:template>


</xsl:stylesheet>

