<?xml version="1.0" encoding="UTF-8"?>
<!--
	Document: usecaseDiagram2svg_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:Model">
		<xsl:param name="xmiDiagramID" />
		
		<!-- Which Diagram to transform? -->
		<xsl:variable name="DiagramID">
			<xsl:choose>
				<!-- Diagram choosen in xmi2svg.xsl -->
				<xsl:when test="$xmiDiagramID"><xsl:value-of select="$xmiDiagramID"/></xsl:when>
				<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='UseCaseDiagram']]/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>
				<!-- weisse Pfeilspitze mit 3 Kanten -->
				<marker id="gen_arrowhead" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="11" markerHeight="11" orient="auto" fill="white">
					<path stroke="black" d="M 0 0 L 10 5 L 0 10"/>
					<path stroke="black" stroke-width="3" d="M 0 0 L 0 10 " />
				</marker>

				<!-- 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>

				<!-- weisse Raute -->
				<marker id="agg_arrowhead" viewBox="0 0 10 10" refX="0" refY="5" markerWidth="11" markerHeight="11" orient="auto" fill="white">
					<path stroke="black" d="M0 5 L5 10 L10 5 L5 0 L0 5"/>
				</marker>                 
				<!-- schwarze Raute -->
				<marker id="com_arrowhead" viewBox="0 0 10 10" refX="0" refY="5" markerWidth="11" markerHeight="11" orient="auto" fill="black">
					<path stroke="black" d="M0 5 L5 10 L10 5 L5 0 L0 5"/>
				</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 Use Cases
		***********************************************************************-->
	<xsl:template match="UML:UseCase">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" /> 
		<xsl:param name="pPackage_y" /> 

		<xsl:variable name="usecaseID" select="@xmi.id"/>
		<xsl:variable name="ucName" select="@name"/>
		<xsl:variable name="isAbstract" select="@isAbstract" />

		<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]/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=$usecaseID]]/XMI.field[position()=2] + $shift_y"/>
		<xsl:variable name="rad_x" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]/XMI.field[position()=1]"/>
		<xsl:variable name="rad_y" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]/XMI.field[position()=2]"/>

		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]/UML:GraphElement.position/XMI.field[position()=1]"/>

		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:choose>
				<xsl:when test="$packageID">					
					<xsl:variable name="temp_2"><xsl:value-of select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=2]"/></xsl:variable>
					<xsl:value-of select="$pPackage_y + $temp_2"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">

			<xsl:comment>**************** Use Case <xsl:value-of select="$ucName"/> ****************</xsl:comment>
	
			<!-- Use Case -->
			<ellipse rx="{$rad_x div 2}" ry="{$rad_y div 2}" cx="{$pos_x + $rad_x div 2 + $package_x}" cy="{$pos_y + $rad_y div 2 + $package_y}" fill="none" stroke="black"/>
	
			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="/XMI/XMI.content/UML:Diagram/UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="namePos_y" select="/XMI/XMI.content/UML:Diagram/UML:GraphElement.contained/UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]"/>
			<xsl:variable name="nameComPos_x" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="nameComPos_y" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[position()=2]" />
	
			<xsl:comment>Name des Use Case</xsl:comment>
	
			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $nameComPos_x + $pos_x + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $nameComPos_y + $pos_y + 10 + $package_y"/></xsl:attribute>
	
				<xsl:attribute name="style">
					<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
					<xsl:if test="$isAbstract = 'true'">font-style:oblique</xsl:if>
				</xsl:attribute>
	
				<tspan>
					<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $nameComPos_x + $pos_x + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $nameComPos_y + $pos_y + 10 + $package_y"/></xsl:attribute>
					<xsl:value-of select="$ucName"/>
				</tspan>
			</text>

			<!-- ID of GraphNode -->
			<xsl:variable name="graphNodeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:UseCase[attribute::xmi.idref=$usecaseID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/@xmi.id" />
			<xsl:variable name="stereoPos_x" select="//UML:GraphNode[descendant::UML:UseCase[attribute::xmi.idref=$usecaseID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="stereoPos_y" select="//UML:GraphNode[descendant::UML:UseCase[attribute::xmi.idref=$usecaseID]]/UML:GraphElement.position/XMI.field[position()=2]" />
			
			<!-- stereotype -->
			<xsl:apply-templates select="UML:ModelElement.stereotype">
				<xsl:with-param name="object_x" select="$stereoPos_x + $nameComPos_x"/>
				<xsl:with-param name="object_y" select="$stereoPos_y + $nameComPos_y"/>
				<xsl:with-param name="package_x" select="$package_x + $shift_x"/>
				<xsl:with-param name="package_y" select="$package_y + $shift_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>

			<!-- Extension Points -->
			<xsl:if test="./UML:UseCase.extensionPoint/UML:ExtensionPoint/@xmi.id">
				<xsl:variable name="extpointID" select="./UML:UseCase.extensionPoint/UML:ExtensionPoint/@xmi.id"/>
				<xsl:variable name="extpointName" select="./UML:UseCase.extensionPoint/UML:ExtensionPoint/@name"/>
				<xsl:variable name="extpointLocation" select="./UML:UseCase.extensionPoint/UML:ExtensionPoint/@location"/>

				<!-- Separator -->
				<xsl:variable name="comSepPos_x" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='CompartmentSeparator']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="comSepPos_y" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='CompartmentSeparator']]/UML:GraphElement.position/XMI.field[position()=2]" />
				<xsl:variable name="comSepWidth" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='CompartmentSeparator']]/UML:GraphNode.size/XMI.field[position()=1]" />
				<xsl:variable name="comSepHeight" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='CompartmentSeparator']]/UML:GraphNode.size/XMI.field[position()=2]" />

				<line x1="{$pos_x + $package_x}" x2="{$pos_x + $comSepWidth + $package_x}" y1="{$pos_y + $comSepPos_y + $package_y}" y2="{$pos_y + $comSepPos_y + $package_y}" style="stroke:black"/>
				<!-- /Separator -->

				<xsl:variable name="extComPos_x" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='ExtensionpointCompartment']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="extComPos_y" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$usecaseID]]//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='ExtensionpointCompartment']]/UML:GraphElement.position/XMI.field[position()=2]" />

				<text>
					<xsl:attribute name="x"><xsl:value-of select="$extComPos_x + $pos_x + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$extComPos_y + $pos_y + 10 + $package_y"/></xsl:attribute>
		
					<xsl:attribute name="style">
						<xsl:text>font-size:11px; font-weight:bold;</xsl:text>
					</xsl:attribute>
		
					<tspan>
						<xsl:attribute name="x"><xsl:value-of select="$extComPos_x + $pos_x + $package_x"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$extComPos_y + $pos_y + 10 + $package_y"/></xsl:attribute>
						Extension Points
					</tspan>
				</text>

				<xsl:variable name="nameExt_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:UseCase[attribute::xmi.idref=$usecaseID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/*[attribute::xmi.idref=$extpointID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="nameExt_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:UseCase[attribute::xmi.idref=$usecaseID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/*[attribute::xmi.idref=$extpointID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]" />
				<xsl:variable name="nameLocSep_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:UseCase[attribute::xmi.idref=$usecaseID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/*[attribute::xmi.idref=$extpointID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='NameLocationSeparator']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="nameLocSep_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:UseCase[attribute::xmi.idref=$usecaseID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/*[attribute::xmi.idref=$extpointID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='NameLocationSeparator']]/UML:GraphElement.position/XMI.field[position()=2]" />
				<xsl:variable name="nameLoc_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:UseCase[attribute::xmi.idref=$usecaseID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/*[attribute::xmi.idref=$extpointID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='Location']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="nameLoc_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:UseCase[attribute::xmi.idref=$usecaseID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/*[attribute::xmi.idref=$extpointID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='Location']]/UML:GraphElement.position/XMI.field[position()=2]" />

				<text>
					<xsl:attribute name="x"><xsl:value-of select="$nameExt_x + $extComPos_x + $pos_x + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$nameExt_y + $extComPos_y + $pos_y + 20 + $package_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="$nameExt_x + $extComPos_x + $pos_x + $package_x"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$nameExt_y + $extComPos_y + $pos_y + 20 + $package_y"/></xsl:attribute>
						<xsl:value-of select="$extpointName"/>
					</tspan>
				</text>
				<text>
					<xsl:attribute name="x"><xsl:value-of select="$nameLocSep_x + $extComPos_x + $pos_x + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$nameLocSep_y + $extComPos_y + $pos_y + 20 + $package_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="$nameLocSep_x + $extComPos_x + $pos_x + $package_x"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$nameLocSep_y + $extComPos_y + $pos_y + 20 + $package_y"/></xsl:attribute>
						:
					</tspan>
				</text>
				<text>
					<xsl:attribute name="x"><xsl:value-of select="$nameLoc_x + $extComPos_x + $pos_x + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$nameLoc_y + $extComPos_y + $pos_y + 20 + $package_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="$nameLoc_x + $extComPos_x + $pos_x + $package_x"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$nameLoc_y + $extComPos_y + $pos_y + 20 + $package_y"/></xsl:attribute>
						<xsl:value-of select="$extpointLocation"/>
					</tspan>
				</text>

			</xsl:if>
			<!-- /Extension Points -->

		</xsl:if>	

	</xsl:template>


	<!--**************************************************
		    ** Darstellung der Generalisierungen **
		    ****************************************************-->
	<xsl:template match="UML:Generalization">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
				
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" /> 
		<xsl:param name="pPackage_y" /> 

		<xsl:variable name="generalizationID" select="@xmi.id"/>
		<xsl:variable name="discriminator" select="@discriminator"/>

		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->
		<xsl:variable name="control" select="//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/UML:GraphEdge.waypoints/XMI.field"/>

		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:choose>
				<xsl:when test="$packageID">					
					<xsl:variable name="temp_2"><xsl:value-of select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=2]"/></xsl:variable>
					<xsl:value-of select="$pPackage_y + $temp_2"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			<xsl:comment>**************** Generalization <xsl:value-of select="$discriminator"/> ****************</xsl:comment>

			<xsl:variable name="waypoints" select="//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/UML:GraphEdge.waypoints/XMI.field"/>
	
			<xsl:if test="$waypoints">
	
				<xsl:variable name="path">
					<xsl:call-template name="buildPath">
						<xsl:with-param name="waypoints" select="//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/UML:GraphEdge.waypoints/XMI.field"/>
						<xsl:with-param name="pos" select="count(//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/UML:GraphEdge.waypoints/XMI.field) -1"/>
						<xsl:with-param name="package_x" select="$package_x + $shift_x"/>
						<xsl:with-param name="package_y" select="$package_y + $shift_y"/>
					</xsl:call-template>
				</xsl:variable>
	
				<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(#gen_arrowhead)</xsl:attribute>
				</path>
	
				<xsl:if test="$discriminator">
					<xsl:variable name="disX" select="//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Discriminator']]/UML:GraphElement.position/XMI.field[position()=1]"/>
					<xsl:variable name="disY" select="//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Discriminator']]/UML:GraphElement.position/XMI.field[position()=2]"/>
					<xsl:text>        
					</xsl:text>
					<text style="font-size:10px">
						<xsl:attribute name="x"><xsl:value-of select="$disX + $package_x + $shift_x"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$disY + 11 + $package_y + $shift_y"/></xsl:attribute>
						<xsl:value-of select="$discriminator"/>
					</text>
				</xsl:if>
	
			</xsl:if>
	
			<!-- ID of GraphNode -->
			<xsl:variable name="graphNodeID" select="//UML:GraphEdge[child::UML:GraphElement.semanticModel/*/*/UML:Generalization[attribute::xmi.idref=$generalizationID]]/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
			<xsl:variable name="stereoPos_x" select="//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="stereoPos_y" select="//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/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="$package_x + $shift_x"/>
				<xsl:with-param name="package_y" select="$package_y + $shift_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>
		</xsl:if>

	</xsl:template>


	<!--**************************************************
	       ** Darstellung der Assoziationen **
	       ****************************************************-->  
	<xsl:template match="UML:Association">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" /> 
		<xsl:param name="pPackage_y" /> 

		<xsl:variable name="associationID" select="@xmi.id" />
		<xsl:variable name="aggregation" select="./UML:Association.connection/UML:AssociationEnd/@aggregation" />
		<xsl:variable name="name" select="@name"/>
		<xsl:variable name="directed" select="./UML:Association.connection/UML:AssociationEnd/@isNavigable"/>
				
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphEdge[descendant::UML:Association[attribute::xmi.idref=$associationID]]/UML:GraphEdge.waypoints/XMI.field" />

		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:choose>
				<xsl:when test="$packageID">					
					<xsl:variable name="temp_2"><xsl:value-of select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=2]"/></xsl:variable>
					<xsl:value-of select="$pPackage_y + $temp_2"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			<xsl:comment>************* Association <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:Association[attribute::xmi.idref=$associationID]]/UML:GraphEdge.waypoints/XMI.field" />
					<xsl:with-param name="pos" select="count(//UML:GraphEdge[descendant::UML:Association[attribute::xmi.idref=$associationID]]/UML:GraphEdge.waypoints/XMI.field) -1" />
					<xsl:with-param name="package_x" select="$package_x + $shift_x" />
					<xsl:with-param name="package_y" select="$package_y + $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:if test="$aggregation= 'aggregate'"><xsl:attribute name="marker-start">url(#agg_arrowhead)</xsl:attribute></xsl:if>
				<xsl:if test="$aggregation= 'composite'"><xsl:attribute name="marker-start">url(#com_arrowhead)</xsl:attribute></xsl:if>
				<xsl:if test="$directed= 'false'"><xsl:attribute name="marker-end">url(#dep_arrowhead)</xsl:attribute></xsl:if>
			</path>         

			<!-- ID of GraphNode -->
			<xsl:variable name="graphNodeID" select="//UML:GraphEdge[child::UML:GraphElement.semanticModel/*/*/UML:Association[attribute::xmi.idref=$associationID]]/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
			<xsl:variable name="stereoPos_x" select="//UML:GraphEdge[descendant::UML:Association[attribute::xmi.idref=$associationID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="stereoPos_y" select="//UML:GraphEdge[descendant::UML:Association[attribute::xmi.idref=$associationID]]/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="$package_x + $shift_x"/>
				<xsl:with-param name="package_y" select="$package_y + $shift_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphEdge[descendant::UML:Association[attribute::xmi.idref=$associationID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='DirectedName']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x"/>
			<xsl:variable name="namePos_y" select="//UML:GraphEdge[descendant::UML:Association[attribute::xmi.idref=$associationID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='DirectedName']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $package_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 + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $package_y"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>

		</xsl:if>	

	</xsl:template>
	

	<!--**************************************************
	       ** Darstellung der Abhängigkeiten **
	       ****************************************************-->  
	<xsl:template match="UML:Dependency">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" /> 
		<xsl:param name="pPackage_y" /> 

		<xsl:variable name="dependencyID" select="@xmi.id" />
		<xsl:variable name="name" select="@name"/>
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/UML:GraphEdge.waypoints/XMI.field" />

		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:comment>************* Dependency <xsl:value-of select="$name"/> *************</xsl:comment>	         

			<xsl:choose>
				<xsl:when test="$packageID">					
					<xsl:variable name="temp_2"><xsl:value-of select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=2]"/></xsl:variable>
					<xsl:value-of select="$pPackage_y + $temp_2"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			<xsl:variable name="path">
				<xsl:call-template name="buildPath">
					<xsl:with-param name="waypoints" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/UML:GraphEdge.waypoints/XMI.field" />
					<xsl:with-param name="pos" select="count(//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/UML:GraphEdge.waypoints/XMI.field) -1" />
					<xsl:with-param name="package_x" select="$package_x + $shift_x" />
					<xsl:with-param name="package_y" select="$package_y + $shift_y" />			
				</xsl:call-template> 
			</xsl:variable>
			
			<!-- Der Pfeil -->
			<path stroke="black" fill="none" stroke-dasharray="5,5"> 
				<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>
			</path>         

			<!-- ID of GraphNode -->
			<xsl:variable name="graphNodeID" select="//UML:GraphEdge[child::UML:GraphElement.semanticModel/*/*/UML:Dependency[attribute::xmi.idref=$dependencyID]]/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
			<xsl:variable name="stereoPos_x" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="stereoPos_y" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/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="$package_x + $shift_x"/>
				<xsl:with-param name="package_y" select="$package_y + $shift_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x"/>
			<xsl:variable name="namePos_y" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $package_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 + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $package_y"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>
		</xsl:if>	

	</xsl:template>
	

	<!--**************************************************
	       ** Darstellung der Includes **
		****************************************************-->  
	<xsl:template match="UML:Include">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" /> 
		<xsl:param name="pPackage_y" /> 

		<xsl:variable name="genID" select="@xmi.id" />
		<xsl:variable name="name" select="@name" />
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphEdge[descendant::UML:Include[attribute::xmi.idref=$genID]]/UML:GraphEdge.waypoints/XMI.field" />
		
		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:choose>
				<xsl:when test="$packageID">					
					<xsl:variable name="temp_2"><xsl:value-of select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=2]"/></xsl:variable>
					<xsl:value-of select="$pPackage_y + $temp_2"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			<xsl:comment>************* Include <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:Include[attribute::xmi.idref=$genID]]/UML:GraphEdge.waypoints/XMI.field" />
					<xsl:with-param name="pos" select="count(//UML:GraphEdge[descendant::UML:Include[attribute::xmi.idref=$genID]]/UML:GraphEdge.waypoints/XMI.field) -1" />
					<xsl:with-param name="package_x" select="$package_x + $shift_x" />
					<xsl:with-param name="package_y" select="$package_y + $shift_y" />
				</xsl:call-template> 
			</xsl:variable>
	
			<!-- Der Pfeil -->    
			<path stroke="black" fill="none" stroke-dasharray="5,5"> 
				<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>
			</path>         
			
			<xsl:variable name="Cx" select="//UML:GraphEdge[descendant::UML:Include[attribute::xmi.idref=$genID]]/descendant::UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='KeywordMetaclass']]/UML:GraphElement.position/XMI.field[position()=1]"></xsl:variable>
			<xsl:variable name="Cy" select="//UML:GraphEdge[descendant::UML:Include[attribute::xmi.idref=$genID]]/descendant::UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='KeywordMetaclass']]/UML:GraphElement.position/XMI.field[position()=2]"></xsl:variable>
			
			<text style="font-size:10px">
				<xsl:attribute name="x"><xsl:value-of select="$Cx + $package_x + $shift_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$Cy + 11 + $package_y + $shift_y"/></xsl:attribute>
				&lt;&lt; include &gt;&gt;
			</text>

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphEdge[descendant::UML:Include[attribute::xmi.idref=$genID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x"/>
			<xsl:variable name="namePos_y" select="//UML:GraphEdge[descendant::UML:Include[attribute::xmi.idref=$genID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $package_y + 11"/></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 + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $package_y + 11"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>
		</xsl:if>

	</xsl:template>
	

	<!--**************************************************
	       ** Darstellung der Extends **
		****************************************************-->  
	<xsl:template match="UML:Extend">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" /> 
		<xsl:param name="pPackage_y" /> 

		<xsl:variable name="genID" select="@xmi.id" />
		<xsl:variable name="name" select="@name" />
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphEdge[descendant::UML:Extend[attribute::xmi.idref=$genID]]/UML:GraphEdge.waypoints/XMI.field" />
		
		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:choose>
				<xsl:when test="$packageID">					
					<xsl:variable name="temp_2"><xsl:value-of select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=2]"/></xsl:variable>
					<xsl:value-of select="$pPackage_y + $temp_2"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			<xsl:comment>************* Extend <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:Extend[attribute::xmi.idref=$genID]]/UML:GraphEdge.waypoints/XMI.field" />
					<xsl:with-param name="pos" select="count(//UML:GraphEdge[descendant::UML:Extend[attribute::xmi.idref=$genID]]/UML:GraphEdge.waypoints/XMI.field) -1" />
					<xsl:with-param name="package_x" select="$package_x + $shift_x" />
					<xsl:with-param name="package_y" select="$package_y + $shift_y" />									
				</xsl:call-template> 
			</xsl:variable>
	
			<!-- Der Pfeil -->    
			<path stroke="black" fill="none" stroke-dasharray="5,5"> 
				<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>
			</path>         
			
			<xsl:variable name="Cx" select="//UML:GraphEdge[descendant::UML:Extend[attribute::xmi.idref=$genID]]/descendant::UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='KeywordMetaclass']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x" />
			<xsl:variable name="Cy" select="//UML:GraphEdge[descendant::UML:Extend[attribute::xmi.idref=$genID]]/descendant::UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='KeywordMetaclass']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y" />
			
			<text style="font-size:10px">
				<xsl:attribute name="x"><xsl:value-of select="$Cx + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$Cy + 11 + $package_y"/></xsl:attribute>
				&lt;&lt; extend &gt;&gt;
			</text>

			<!-- x und y Position des Namens -->
			<xsl:variable name="namePos_x" select="//UML:GraphEdge[descendant::UML:Extend[attribute::xmi.idref=$genID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x"/>
			<xsl:variable name="namePos_y" select="//UML:GraphEdge[descendant::UML:Extend[attribute::xmi.idref=$genID]]/*/UML:GraphNode[descendant::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y"/>

			<text>
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $package_y + 11"/></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 + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $package_y + 11"/></xsl:attribute>
					<xsl:value-of select="$name"/>
				</tspan>
			</text>
		</xsl:if>

	</xsl:template>
	

	<!--**************************************************
		    ** Darstellung der Aktoren **
		    ****************************************************-->
	<xsl:template match="UML:Actor">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" /> 
		<xsl:param name="pPackage_y" /> 

		<xsl:variable name="actorID" select="@xmi.id"/>
		<xsl:variable name="actorName" select="@name"/>
		<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$actorID]]/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=$actorID]]/XMI.field[position()=2] + $shift_y"/>
		<xsl:variable name="width_x" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$actorID]]/XMI.field[position()=1]"/>
		<xsl:variable name="width_y" select="//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$actorID]]/XMI.field[position()=2]"/>


		<!-- x und y Position des Namens -->
		<xsl:variable name="namePos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//UML:Actor[attribute::xmi.idref=$actorID]]/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:Actor[attribute::xmi.idref=$actorID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]"/>

		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$actorID]]/UML:GraphElement.position/XMI.field[position()=1]"/>

		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:choose>
				<xsl:when test="$packageID">					
					<xsl:variable name="temp_2"><xsl:value-of select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=2]"/></xsl:variable>
					<xsl:value-of select="$pPackage_y + $temp_2"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			<xsl:comment>************* Actor <xsl:value-of select="$actorName"/> *************</xsl:comment>	         

			<circle cx="{$pos_x + $width_x div 2 + $package_x}" cy="{$pos_y + $width_x div 2 + $package_y}" r="{$width_x div 3}" style="stroke:rgb(0,0,0);stroke-width:1;fill:none"/>
			<line x1="{$pos_x + $width_x div 2 + $package_x}" y1="{$pos_y + ($width_x div 3) + $width_x div 2 + $package_y}" x2="{$pos_x + $width_x div 2 + $package_x}" y2="{$pos_y + ($width_x div 3) + (($width_y div 2) - ($width_x div 3)) + $width_x div 2 + $package_y}" style="fill:none;stroke:rgb(0,0,0);stroke-width:1"/>
			<line x1="{$pos_x + $width_x div 2 + $package_x}" y1="{$pos_y + ($width_x div 3) + (($width_y div 2) - ($width_x div 3)) + $width_x div 2 + $package_y}" x2="{$pos_x - ($width_x div 2) + $width_x div 2 + $package_x}" y2="{$pos_y + ($width_x div 3) + (($width_y div 2) - ($width_x div 3)) + (($width_y div 2) - ($width_x div 3)) + $width_x div 2 + $package_y}" style="fill:none;stroke:rgb(0,0,0);stroke-width:1"/>
			<line x1="{$pos_x + $width_x div 2 + $package_x}" y1="{$pos_y + ($width_x div 3) + (($width_y div 2) - ($width_x div 3)) + $width_x div 2 + $package_y}" x2="{$pos_x + ($width_x div 2) + $width_x div 2 + $package_x}" y2="{$pos_y + ($width_x div 3) + (($width_y div 2) - ($width_x div 3)) + (($width_y div 2) - ($width_x div 3)) + $width_x div 2 + $package_y}" style="fill:none;stroke:rgb(0,0,0);stroke-width:1"/>
			<line x1="{$pos_x + $package_x}" y1="{$pos_y + $width_x + $package_y}" x2="{$pos_x + $width_x + $package_x}" y2="{$pos_y + $width_x + $package_y}" style="fill:none;stroke:rgb(0,0,0);stroke-width:1"/>
	
			<text x="{$namePos_x + $pos_x + $package_x}" y="{$namePos_y + $pos_y + 18 + $package_y}">
				<xsl:value-of select="$actorName"/>
			</text>

			<!-- ID of GraphEdge -->
			<xsl:variable name="graphNodeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Actor[attribute::xmi.idref=$actorID]]/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/@xmi.id" />
			<xsl:variable name="stereoPos_x" select="//UML:GraphNode[descendant::UML:Actor[attribute::xmi.idref=$actorID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="stereoPos_y" select="//UML:GraphNode[descendant::UML:Actor[attribute::xmi.idref=$actorID]]/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="$package_x + $shift_x"/>
				<xsl:with-param name="package_y" select="$package_y + $shift_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>
		</xsl:if>
	</xsl:template>


	<!--*******************************************
	       ** Die Darstellung der einzelnen Packages   **
	       *********************************************-->      
	<xsl:template match="UML:Package">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="isAbstract" select="@isAbstract" />
		<xsl:variable name="name" select="@name" />
		<xsl:variable name="visibility" select="@visibility" />
		<xsl:variable name="packageID" select="@xmi.id" />
		
		<xsl:variable name="pos_x" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x" />
		<xsl:variable name="pos_y" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y" />
	         
		<xsl:if test="$pos_x">

			<xsl:comment>************* Package <xsl:value-of select="$name"/> *************</xsl:comment>	         

			<xsl:variable name="width" select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphNode.size/XMI.field[position()=1]" />
			<xsl:variable name="height" select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphNode.size/XMI.field[position()=2]" />
			
			<xsl:variable name="nc_width" select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=1]" />
			<xsl:variable name="nc_height" select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphNode.size/XMI.field[position()=2]" />    
			
			<!-- Name Compartment -->
			<rect x="{$pos_x}" y="{$pos_y}" height="{$nc_height}" width="{$nc_width}" fill="white" stroke="black" />
			
			<!-- Package -->
			<rect x="{$pos_x}" y="{$pos_y + $nc_height}" height="{$height - $nc_height}" 	width="{$width}" fill="white" stroke="black" />
			
			<xsl:variable name="namePos_x" select="//UML:GraphNode[child::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x" />
			<xsl:variable name="namePos_y" select="//UML:GraphNode[child::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y" />
			
			<text style="font-size:11px">
				<xsl:attribute name="x"><xsl:value-of select="$pos_x + $namePos_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$pos_y + $namePos_y  + 11"/></xsl:attribute>
				<xsl:value-of select="$name"/>
			</text>
			
			<xsl:variable name="visibilityVisible" select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/attribute::isVisible" />
			
			<xsl:if test="$visibilityVisible = 'true' ">
				<xsl:variable name="visPos_x" select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/UML:GraphElement.position/XMI.field[position()=1] + $shift_x" />
				<xsl:variable name="visPos_y" select="//UML:Diagram/UML:GraphElement.contained/UML:GraphNode[descendant::*/*/*/UML:Package[attribute::xmi.idref=$packageID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/UML:GraphElement.position/XMI.field[position()=2] + $shift_y" />
				
				<text>
					<xsl:attribute name="style">
						<xsl:text>font-size:11px; font-weight:normal;</xsl:text>
						<xsl:if test="$isAbstract = 'true'">font-style:oblique</xsl:if>
					</xsl:attribute>
					<xsl:attribute name="x"><xsl:value-of select="$pos_x + $visPos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$pos_y + $visPos_y + 11"/></xsl:attribute>
					<xsl:call-template name="getVisibility">
						<xsl:with-param name="visibility" select="$visibility" />
					</xsl:call-template>	
				</text>		
			</xsl:if>
			
			<!-- ID of GraphNode -->
			<xsl:variable name="graphNodeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Package[attribute::xmi.idref=$packageID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
			
			<xsl:apply-templates select="UML:ModelElement.stereotype">
				<xsl:with-param name="object_x" select="$pos_x"/>
				<xsl:with-param name="object_y" select="$pos_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: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:with-param name="packageID" select="$packageID" />
				<xsl:with-param name="pPackage_x" select="$pos_x" />
				<xsl:with-param name="pPackage_y" select="$pos_y" />
			</xsl:apply-templates>

		</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>

