<?xml version="1.0" encoding="UTF-8" ?>

<!--
    Document   : xmi2svg.xsl
    Created on : September 14, 2003, 2:31 PM
    Author     : Bastian Stritt
    Description:
        Purpose of transformation follows.
-->

<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:param name="diagramID" />
	
	<xsl:template match="text()" />   
    
	<!-- ********************************************************
	        ** 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 DeploymentDiagram found in XMI-File -->
				<xsl:otherwise>
				   	<xsl:value-of select="//UML:Diagram[position()=1][child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='DeploymentDiagram']]/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 + 30"/></xsl:attribute>
			<xsl:attribute name="height"><xsl:value-of select="$height + $shift_y + 30"/></xsl:attribute>		
			<defs>
				<!-- schwarze Pfeilspitze mit 3 Kanten -->
				<marker id="start_black_arrowhead" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="11" markerHeight="11" orient="0" fill="black">
					<path stroke="black" d="M 0 0 L 10 5 L 0 10 z"/>
				</marker>
				<marker id="start2_black_arrowhead" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="11" markerHeight="11" orient="180" fill="black">
					<path stroke="black" d="M 0 0 L 10 5 L 0 10 z"/>
				</marker>
				<marker id="end_black_arrowhead" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="11" markerHeight="11" orient="auto" fill="black">
					<path stroke="black" d="M 0 0 L 10 5 L 0 10 z"/>
				</marker>
				
				<!-- transparente Pfeilspitze, nur mit den Pfeilkanten -->
				<marker id="start_trans_arrowhead" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="11" markerHeight="11" orient="0" fill="none">
					<path stroke="black" d="M 0 0 L 10 5 L 0 10"/>
				</marker>                
				<marker id="start2_trans_arrowhead" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="11" markerHeight="11" orient="180" fill="none">
					<path stroke="black" d="M 0 0 L 10 5 L 0 10"/>
				</marker>                
				<marker id="end_trans_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>                   
				
				<!-- 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>			
			</defs>
			
			<xsl:apply-templates select="*/UML:Node"  mode="deploymentdiagramm">
				<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>			
			<xsl:apply-templates select="*/UML:Association">
				<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>			
			<xsl:apply-templates select="*/UML:Dependency">			
				<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>			
			<xsl:apply-templates select="*/UML:NodeInstance"  mode="deploymentdiagramm">
				<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>			
			<xsl:apply-templates select="*/UML:Component"  mode="deploymentdiagramm">
				<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>			
			<xsl:apply-templates select="*/UML:ComponentInstance"  mode="deploymentdiagramm">
				<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>			
			<xsl:apply-templates select="*/UML:Object" mode="deploymentdiagramm">
				<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>			
			<xsl:apply-templates select="*/UML:Class">
				<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>			
			<xsl:apply-templates select="*/UML:Interface">			
				<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>			
			<xsl:apply-templates select="*/UML:Abstraction">			
				<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>			
			<xsl:apply-templates select="*/UML:Generalization">					
				<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>			
			<xsl:apply-templates select="*/UML:Comment" mode="package">
				<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>

	<xsl:template match="UML:Object" mode="deploymentdiagramm">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="name" select="@name" />
		<xsl:variable name="id" select="@xmi.id" />
		
		<xsl:variable name="classifierID" select="UML:Instance.classifier/*/attribute::xmi.idref" />
		<xsl:variable name="classifierName" select="//*[attribute::xmi.id=$classifierID]/attribute::name" />

		<!-- x/y Position + height/width  des Objects -->
		<xsl:variable name="pos_x" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[attribute::xmi.idref=$id]]/UML:GraphElement.position/XMI.field[position()=1]"/>
		
		<xsl:if test="$pos_x">
			<xsl:variable name="pos_y" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[attribute::xmi.idref=$id]]/UML:GraphElement.position/XMI.field[position()=2]"/>
			<xsl:variable name="width" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[attribute::xmi.idref=$id]]/UML:GraphNode.size/XMI.field[position()=1]"/>
			<xsl:variable name="height" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[attribute::xmi.idref=$id]]/UML:GraphNode.size/XMI.field[position()=2]"/>		
	
			<!-- x/y Position + height/width  des NameCompartments -->
			<xsl:variable name="ncPos_x" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[attribute::xmi.idref=$id]]//UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[position()=1]" />		
			<xsl:variable name="ncPos_y" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[attribute::xmi.idref=$id]]//UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[position()=2]" />
			
			<!-- x/y Position + height/width  des Name/Types -->		
			<xsl:variable name="ntPos_x" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[attribute::xmi.idref=$id]]//UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameAndType']]/UML:GraphElement.position/XMI.field[position()=1]" />		
			<xsl:variable name="ntPos_y" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[attribute::xmi.idref=$id]]//UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameAndType']]/UML:GraphElement.position/XMI.field[position()=2]" />		
	
			<!-- x/y Position + height/width  des Names -->
			<xsl:variable name="namePos_x" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[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[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::*/*/*/UML:Object[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]" />
	
			<xsl:text>
			</xsl:text>
		
			<line x1="{$pos_x + ($width div 2) + $shift_x}" x2="{$pos_x + $width div 2 + $shift_x}" y1="{$pos_y + $shift_y}" y2="{$pos_y + $shift_y}" style="stroke:black;stroke-width=5;" stroke-dasharray="5,5"/>						
	
			<xsl:text>
			</xsl:text>
			<xsl:comment>Object Header</xsl:comment>
			<xsl:text>
			</xsl:text>
			
			<!-- aktiviert? -->
			<xsl:variable name="tagDefinitionID" select="UML:ModelElement.taggedValue//UML:TagDefinition/attribute::xmi.idref" />
			<xsl:variable name="tagDefinitionValue" select="UML:ModelElement.taggedValue//UML:TaggedValue.dataValue" />		
			<xsl:text>
			</xsl:text>
			
			<rect 	x="{$pos_x +  $shift_x}" y="{$pos_y  + $shift_y}"
				height="{$height}"
				width="{$width}" fill="none" stroke="black">
				<xsl:if test="$tagDefinitionValue = 'true'">
					<xsl:if test="//UML:TagDefinition[attribute::xmi.id=$tagDefinitionID]/attribute::name = 'isActive' ">
						<xsl:attribute name="stroke-width">3</xsl:attribute>								
					</xsl:if>
				</xsl:if>
			</rect>				
			<xsl:text>
			</xsl:text>
			<!-- Objektname -->				
			<text style="text-decoration:underline;font-size:11px">
				<xsl:attribute name="x"><xsl:value-of select="$pos_x + $ncPos_x + $namePos_x + $shift_x"/> </xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$pos_y + $ncPos_y + $namePos_y + 12 + $shift_y"/> </xsl:attribute>
				<xsl:value-of select="$name"/>
				<xsl:if test="$classifierName">
					:<xsl:value-of select="$classifierName"/>
				</xsl:if>
			</text>
			
			<xsl:apply-templates select="*/UML:Link" mode="deploymentDiagramm" />
			
		</xsl:if>
	</xsl:template>	   
    
    
    	<!-- UML:Component -->
    	<xsl:template match="UML:Component" mode="deploymentdiagramm">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
    		
    		<xsl:variable name="componentID" select="@xmi.id" />
    		<xsl:variable name="componentName" select="@name" />
    		<xsl:variable name="isAbstract" select="@isAbstract" />
    		
    		<xsl:variable name="component_x" select="//UML:Diagram[attribute::xmi.id=$DiagramID]//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Component[attribute::xmi.idref=$componentID]]/UML:GraphElement.position/XMI.field[1]" />

		<xsl:if test="$component_x">

	    		<xsl:variable name="component_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Component[attribute::xmi.idref=$componentID]]/UML:GraphElement.position/XMI.field[2]" />
	    		
	    		<xsl:variable name="componentWidth" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Component[attribute::xmi.idref=$componentID]]/UML:GraphNode.size/XMI.field[1]" />
	    		<xsl:variable name="componentHeight" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Component[attribute::xmi.idref=$componentID]]/UML:GraphNode.size/XMI.field[2]" />
	
			<xsl:variable name="nameCompartment_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Component[attribute::xmi.idref=$componentID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[1]" />
			<xsl:variable name="nameCompartment_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Component[attribute::xmi.idref=$componentID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[2]" />
			
			<xsl:variable name="name_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Component[attribute::xmi.idref=$componentID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[1]" />	
			<xsl:variable name="name_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Component[attribute::xmi.idref=$componentID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[2]" />	
			
	
			<rect x="{$shift_x + $component_x}" y="{$shift_y + $component_y}"
				width="{$componentWidth}" height="{$componentHeight}" fill="white" stroke="black" />
	    	
			<text>
				<xsl:attribute name="style">
					<xsl:text>font-size:11px;</xsl:text>
					<xsl:if test="$isAbstract = 'true'">font-style:oblique</xsl:if> <!-- abstract -->				
				</xsl:attribute>			
			
				<xsl:attribute name="x"><xsl:value-of select="$shift_x + $component_x + $nameCompartment_x + $name_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$shift_y + $component_y + $nameCompartment_y + $name_y + 11"/></xsl:attribute>
				<xsl:value-of select="$componentName"/>
			</text>
			
			<rect x="{$shift_x + $component_x - 10}" y="{$shift_y + $component_y + 20}"
				width="20" height="10" fill="white" stroke="black"/>
	
			<rect x="{$shift_x + $component_x - 10}" y="{$shift_y + $component_y + 35}"
				width="20" height="10" fill="white" stroke="black"/>
		</xsl:if>
    	</xsl:template>
    
    	<!-- UML:Component -->
    	<xsl:template match="UML:ComponentInstance" mode="deploymentdiagramm">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
    		
    		<xsl:variable name="componentID" select="@xmi.id" />
    		<xsl:variable name="componentName" select="@name" />
    		<xsl:variable name="isAbstract" select="@isAbstract" />
    		
		<!-- Type of Attribute -->
		<xsl:variable name="dataTypeID" select="UML:Instance.classifier/UML:DataType/attribute::xmi.idref" />        
		<xsl:variable name="dataType" select="//UML:DataType[attribute::xmi.id=$dataTypeID]/attribute::name" />
    		
    		<xsl:variable name="component_x" select="//UML:Diagram[attribute::xmi.id=$DiagramID]//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ComponentInstance[attribute::xmi.idref=$componentID]]/UML:GraphElement.position/XMI.field[1]" />

		<xsl:if test="$component_x">
	    		
	    		<xsl:variable name="component_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ComponentInstance[attribute::xmi.idref=$componentID]]/UML:GraphElement.position/XMI.field[2]" />
	    		
	    		<xsl:variable name="componentWidth" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ComponentInstance[attribute::xmi.idref=$componentID]]/UML:GraphNode.size/XMI.field[1]" />
	    		<xsl:variable name="componentHeight" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ComponentInstance[attribute::xmi.idref=$componentID]]/UML:GraphNode.size/XMI.field[2]" />
	
			<xsl:variable name="nameCompartment_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ComponentInstance[attribute::xmi.idref=$componentID]]//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[1]" />
			<xsl:variable name="nameCompartment_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ComponentInstance[attribute::xmi.idref=$componentID]]//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[2]" />
			
			<xsl:variable name="name_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ComponentInstance[attribute::xmi.idref=$componentID]]//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[1]" />	
			<xsl:variable name="name_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:ComponentInstance[attribute::xmi.idref=$componentID]]//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[2]" />	
			
	
			<rect x="{$shift_x + $component_x}" y="{$shift_y + $component_y}"
				width="{$componentWidth}" height="{$componentHeight}" fill="white" stroke="black" />
	    	
			<text>
				<xsl:attribute name="style">
					<xsl:text>font-size:11px;text-decoration:underline;</xsl:text>				
					<xsl:text>font-size:11px;</xsl:text>
					<xsl:if test="$isAbstract = 'true'">font-style:oblique</xsl:if> <!-- abstract -->				
				</xsl:attribute>			
			
				<xsl:attribute name="x"><xsl:value-of select="$shift_x + $component_x + $nameCompartment_x + $name_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$shift_y + $component_y + $nameCompartment_y + $name_y + 11"/></xsl:attribute>
				<xsl:value-of select="$componentName"/>
				<xsl:if test="$dataType">
					:<xsl:value-of select="$dataType"/>           
				</xsl:if>			
				
			</text>
			
			<rect x="{$shift_x + $component_x - 10}" y="{$shift_y + $component_y + 20}"
				width="20" height="10" fill="white" stroke="black"/>
	
			<rect x="{$shift_x + $component_x - 10}" y="{$shift_y + $component_y + 35}"
				width="20" height="10" fill="white" stroke="black"/>
		</xsl:if>
    	</xsl:template>
    
    
    	<!-- UML:Node -->
	<xsl:template match="UML:Node" mode="deploymentdiagramm">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="nodeID" select="@xmi.id" />
		<xsl:variable name="nodeName" select="@name" />
    		<xsl:variable name="isAbstract" select="@isAbstract" />
		
		<xsl:variable name="node_x" select="//UML:Diagram[attribute::xmi.id=$DiagramID]//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Node[attribute::xmi.idref=$nodeID]]/UML:GraphElement.position/XMI.field[1]" />
		<xsl:if test="$node_x">
			<xsl:variable name="node_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Node[attribute::xmi.idref=$nodeID]]/UML:GraphElement.position/XMI.field[2] + 20" />	
			
			<xsl:variable name="nodeWidth" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Node[attribute::xmi.idref=$nodeID]]/UML:GraphNode.size/XMI.field[1] - 20" />		
			<xsl:variable name="nodeHeight" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Node[attribute::xmi.idref=$nodeID]]/UML:GraphNode.size/XMI.field[2] - 20" />
			
			<rect x="{$shift_x + $node_x}" y="{$shift_y + $node_y}"
				width="{$nodeWidth}" height="{$nodeHeight}" fill="white" stroke="black" />
			
			<!-- links oben -->
			<line x1="{$shift_x + $node_x}" y1="{$shift_y + $node_y}" x2="{$shift_x + $node_x + 20} " y2="{$shift_y + $node_y - 20 }" style="stroke:black;stroke-width=5"/>
			<!-- rechts oben -->
			<line x1="{$shift_x + $node_x + $nodeWidth}" y1="{$shift_y + $node_y}" x2="{$shift_x + $node_x + 20 + $nodeWidth} " y2="{$shift_y + $node_y - 20 }" style="stroke:black;stroke-width=5"/>
			<!-- rechts unten -->
			<line x1="{$shift_x + $node_x + $nodeWidth}" y1="{$shift_y + $node_y + $nodeHeight}" x2="{$shift_x + $node_x + 20 + $nodeWidth} " y2="{$shift_y + $node_y + $nodeHeight - 20 }" style="stroke:black;stroke-width=5"/>
	
			<line x1="{$shift_x + $node_x + 20} " y1="{$shift_y + $node_y - 20 }"	x2="{$shift_x + $node_x + 20 + $nodeWidth} " y2="{$shift_y + $node_y - 20 }"  style="stroke:black;stroke-width=5" />
			<line  x1="{$shift_x + $node_x + 20 + $nodeWidth} " y1="{$shift_y + $node_y - 20 }" x2="{$shift_x + $node_x + 20 + $nodeWidth} " y2="{$shift_y + $node_y + $nodeHeight - 20 }" style="stroke:black;stroke-width=5" />
	
			<xsl:variable name="nameCompartment_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Node[attribute::xmi.idref=$nodeID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[1]" />
			<xsl:variable name="nameCompartment_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Node[attribute::xmi.idref=$nodeID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[2]" />
			
			<xsl:variable name="name_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Node[attribute::xmi.idref=$nodeID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[1]" />	
			<xsl:variable name="name_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Node[attribute::xmi.idref=$nodeID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[2]" />	
		
			<text>
				<xsl:attribute name="style">
					<xsl:text>font-size:11px;</xsl:text>
					<xsl:if test="$isAbstract = 'true'">font-style:oblique</xsl:if> <!-- abstract -->					
				</xsl:attribute>			
				<xsl:attribute name="x"><xsl:value-of select="$shift_x + $node_x + $nameCompartment_x + $name_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$shift_y + $node_y + $nameCompartment_y + $name_y - 8"/></xsl:attribute>
				<xsl:value-of select="$nodeName"/>
			</text>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="UML:NodeInstance" mode="deploymentdiagramm">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="nodeID" select="@xmi.id" />
		<xsl:variable name="nodeName" select="@name" />
    		<xsl:variable name="isAbstract" select="@isAbstract" />
		
		<!-- Type of Attribute -->
		<xsl:variable name="dataTypeID" select="UML:Instance.classifier/UML:DataType/attribute::xmi.idref" />        
		<xsl:variable name="dataType" select="//UML:DataType[attribute::xmi.id=$dataTypeID]/attribute::name" />
		
		<xsl:variable name="node_x" select="//UML:Diagram[attribute::xmi.id=$DiagramID]//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:NodeInstance[attribute::xmi.idref=$nodeID]]/UML:GraphElement.position/XMI.field[1]" />

		<xsl:if test="$node_x">
		
			<xsl:variable name="node_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:NodeInstance[attribute::xmi.idref=$nodeID]]/UML:GraphElement.position/XMI.field[2] + 20" />	
			
			<xsl:variable name="nodeWidth" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:NodeInstance[attribute::xmi.idref=$nodeID]]/UML:GraphNode.size/XMI.field[1] - 20" />		
			<xsl:variable name="nodeHeight" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:NodeInstance[attribute::xmi.idref=$nodeID]]/UML:GraphNode.size/XMI.field[2] - 20" />
			
			<rect x="{$shift_x + $node_x}" y="{$shift_y + $node_y}"
				width="{$nodeWidth}" height="{$nodeHeight}" fill="white" stroke="black" />
			
			<!-- links oben -->
			<line x1="{$shift_x + $node_x}" y1="{$shift_y + $node_y}" x2="{$shift_x + $node_x + 20} " y2="{$shift_y + $node_y - 20 }" style="stroke:black;stroke-width=5"/>
			<!-- rechts oben -->
			<line x1="{$shift_x + $node_x + $nodeWidth}" y1="{$shift_y + $node_y}" x2="{$shift_x + $node_x + 20 + $nodeWidth} " y2="{$shift_y + $node_y - 20 }" style="stroke:black;stroke-width=5"/>
			<!-- rechts unten -->
			<line x1="{$shift_x + $node_x + $nodeWidth}" y1="{$shift_y + $node_y + $nodeHeight}" x2="{$shift_x + $node_x + 20 + $nodeWidth} " y2="{$shift_y + $node_y + $nodeHeight - 20 }" style="stroke:black;stroke-width=5"/>
	
			<line x1="{$shift_x + $node_x + 20} " y1="{$shift_y + $node_y - 20 }"	x2="{$shift_x + $node_x + 20 + $nodeWidth} " y2="{$shift_y + $node_y - 20 }"  style="stroke:black;stroke-width=5" />
			<line  x1="{$shift_x + $node_x + 20 + $nodeWidth} " y1="{$shift_y + $node_y - 20 }" x2="{$shift_x + $node_x + 20 + $nodeWidth} " y2="{$shift_y + $node_y + $nodeHeight - 20 }" style="stroke:black;stroke-width=5" />
	
			<xsl:variable name="nameCompartment_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:NodeInstance[attribute::xmi.idref=$nodeID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[1]" />
			<xsl:variable name="nameCompartment_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:NodeInstance[attribute::xmi.idref=$nodeID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]/UML:GraphElement.position/XMI.field[2]" />
			
			<xsl:variable name="name_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:NodeInstance[attribute::xmi.idref=$nodeID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[1]" />	
			<xsl:variable name="name_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:NodeInstance[attribute::xmi.idref=$nodeID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='NameCompartment']]//UML:GraphNode[child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[2]" />	
		
			<text>
				<xsl:attribute name="style">
					<xsl:text>font-size:11px;text-decoration:underline;</xsl:text>
					<xsl:if test="$isAbstract = 'true'">font-style:oblique</xsl:if> <!-- abstract -->					
				</xsl:attribute>			
				<xsl:attribute name="x"><xsl:value-of select="$shift_x + $node_x + $nameCompartment_x + $name_x + 2"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$shift_y + $node_y + $nameCompartment_y + $name_y - 8 + 2"/></xsl:attribute>
				<xsl:value-of select="$nodeName"/>
				<xsl:if test="$dataType">
					:<xsl:value-of select="$dataType"/>           
				</xsl:if>
			</text>
			
			<xsl:apply-templates select="*/UML:Link" mode="deploymentDiagramm" />
		</xsl:if>
	</xsl:template>
	
	<!-- ************************
	        ** Die einzelnen Links **
	        ************************ -->	
	<xsl:template match="UML:Link" mode="deploymentDiagramm">
		<xsl:param name="DiagramID" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="id" select="@xmi.id" />

		<!-- Die ID des zugehörigen UML:GraphEdge -->
		<xsl:variable name="edgeID" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][descendant::UML:Link[attribute::xmi.idref=$id]]/attribute::xmi.id" />
		
		<xsl:if test="$edgeID">
	
			<!-- Die IDs der beiden Connectoren -->
			<xsl:variable name="connectorID_1" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][attribute::xmi.id=$edgeID]/UML:GraphEdge.anchor/UML:GraphConnector[position()=1]/attribute::xmi.idref" />
			<xsl:variable name="connectorID_2" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][attribute::xmi.id=$edgeID]/UML:GraphEdge.anchor/UML:GraphConnector[position()=2]/attribute::xmi.idref" />
			
			<xsl:variable name="actionType" select="local-name(//UML:Stimulus[child::UML:Stimulus.communicationLink/UML:Link[attribute::xmi.idref=$id]]/UML:Stimulus.dispatchAction/*)" />
		
			<!-- Die ID des Receivers des Stimulus (da wo die Pfeilspitze ist) -->
			<xsl:variable name="receiverID" select="//UML:Stimulus[child::UML:Stimulus.communicationLink/UML:Link[attribute::xmi.idref=$id]]/UML:Stimulus.receiver/*/attribute::xmi.idref" />
			
			<xsl:variable name="stimulusName" select="//UML:Stimulus[child::UML:Stimulus.communicationLink/UML:Link[attribute::xmi.idref=$id]]/attribute::name" />
			<xsl:variable name="stimulusID" select="//UML:Stimulus[child::UML:Stimulus.communicationLink/UML:Link[attribute::xmi.idref=$id]]/attribute::xmi.id" />
	
			<xsl:variable name="ActionID" select="//UML:Stimulus[child::UML:Stimulus.communicationLink/UML:Link[attribute::xmi.idref=$id]]/UML:Stimulus.dispatchAction/*/attribute::xmi.idref" />
			<xsl:variable name="ActionName" select="//*[attribute::xmi.id=$ActionID]/attribute::name" />		
			
			<xsl:variable name="stimPos_x" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel/*/*/UML:Stimulus[attribute::xmi.idref=$stimulusID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="stimPos_y" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel/*/*/UML:Stimulus[attribute::xmi.idref=$stimulusID]]/UML:GraphElement.position/XMI.field[position()=2]" />		
			
			<xsl:variable name="arrow_x" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel/*[attribute::typeInfo='Arrow']][ancestor::UML:GraphEdge[attribute::xmi.id=$edgeID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="arrow_y" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel/*[attribute::typeInfo='Arrow']][ancestor::UML:GraphEdge[attribute::xmi.id=$edgeID]]/UML:GraphElement.position/XMI.field[position()=2]" />		
			<xsl:variable name="arrow_width" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel/*[attribute::typeInfo='Arrow']][ancestor::UML:GraphEdge[attribute::xmi.id=$edgeID]]/UML:GraphNode.size/XMI.field[position()=1]" />
			<xsl:variable name="arrow_height" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel/*[attribute::typeInfo='Arrow']][ancestor::UML:GraphEdge[attribute::xmi.id=$edgeID]]/UML:GraphNode.size/XMI.field[position()=2]" />		
			
			<xsl:variable name="path">
				<xsl:call-template name="buildPath">
					<xsl:with-param name="waypoints" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][descendant::UML:Link[attribute::xmi.idref=$id]]/UML:GraphEdge.waypoints/XMI.field" />
					<xsl:with-param name="pos" select="count(//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][descendant::UML:Link[attribute::xmi.idref=$id]]/UML:GraphEdge.waypoints/XMI.field) -1" />
					<xsl:with-param name="package_x" select="0 + $shift_x" />
					<xsl:with-param name="package_y" select="0 + $shift_y" />							
				</xsl:call-template> 
			</xsl:variable>
			
			<xsl:text>
			</xsl:text>
			
			<!-- Die Linie -->    
			<path stroke="black" fill="none"> 
				<xsl:attribute name="d">M<xsl:value-of select="substring-after($path,'L')"/></xsl:attribute>
			</path>		
	
			<xsl:text>
			</xsl:text>
			
			<xsl:if test="$stimPos_x">
				
				<!-- Die Connectoren sind ordered. D.h. der erste Connector ist dem ersten Waypoint des GraphEdge zugeordnet. Der 2. Connector dem letzten Waypoint. 
					Hier teste ich nun, welcher Connector der erste ist -->
				<xsl:variable name="connectorTest_1" select="//UML:GraphConnector[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][attribute::xmi.id=$connectorID_1][following::UML:GraphConnector[attribute::xmi.id=$connectorID_2]]" />		
			
				<!-- Hier teste ich ob die connectorID_1 unterhalb der Activation des Receiver-Objects angeordnet ist. Wenn ja, dann muß an diesen Connector die Pfeilspitze angebracht werden -->
				<xsl:variable name="connectorTest_3" select=" //UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][child::UML:GraphElement.semanticModel/UML:SimpleSemanticModelElement[attribute::typeInfo='Activation']][child::UML:GraphElement.anchorage/UML:GraphConnector[attribute::xmi.id=$connectorID_1]][../../UML:GraphElement.semanticModel/*/*/UML:Object[attribute::xmi.idref=$receiverID]]" />
				
				<!-- Der Pfeil -->    
				<path stroke="black" fill="none"> 
					<xsl:attribute name="d">M<xsl:value-of select="$stimPos_x + $arrow_x + $shift_x"/>,<xsl:value-of select="$stimPos_y + $arrow_y + ($arrow_height div 2) + $shift_y"/> L<xsl:value-of select="$stimPos_x + $arrow_x + $shift_x + $arrow_width"/>,<xsl:value-of select="$stimPos_y + $arrow_y + ($arrow_height div 2) + $shift_y"/></xsl:attribute>
					<xsl:choose>
						<xsl:when test="$connectorTest_1"><!-- connectorID_1 ist vor connectorID_2 -->
							<xsl:if test="$connectorTest_3"><!-- connectorID_1 ist unterhalb der Activation des Receiver-Objects -->
								<xsl:attribute name="marker-start">url(#start2_black_arrowhead)</xsl:attribute>
							</xsl:if>
							<xsl:if test="not($connectorTest_3)"><!-- connectorID_1 ist nicht unterhalb der Activation des Receiver-Objects -->
								<xsl:attribute name="marker-end">url(#end_black_arrowhead)</xsl:attribute>
							</xsl:if>					
						</xsl:when>
						<xsl:when test="not($connectorTest_1)"><!-- connectorID_2 ist vor connectorID_1 -->
							<xsl:if test="$connectorTest_3"><!-- connectorID_1 ist unterhalb der Activation des Receiver-Objects -->
								<xsl:attribute name="marker-start">url(#start_black_arrowhead)</xsl:attribute>
							</xsl:if>
							<xsl:if test="not($connectorTest_3)"><!-- connectorID_1 ist nicht unterhalb der Activation des Receiver-Objects -->
								<xsl:attribute name="marker-end">url(#end_black_arrowhead)</xsl:attribute>
							</xsl:if>
						</xsl:when>				
					</xsl:choose>			
				</path>		
	
				<!-- Name des Stimulus -->
				<text style="font-size:11px">
					<xsl:attribute name="x"><xsl:value-of select="$stimPos_x + $shift_x + $arrow_width"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$stimPos_y + 12 + $shift_y"/></xsl:attribute>
					<xsl:value-of select="$stimulusName"/>:<xsl:value-of select="$ActionName"/>
					<xsl:if test="$ActionName='' ">anonym</xsl:if>
				</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>
	
	<!--**************************************************
	       ** Die Darstellung der einzelnen 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" />
		<xsl:variable name="abstract" select="@isAbstract" />
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][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 + $shift_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_x"/></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 + $shift_y"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_y"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			<!-- Stereotype -->
			<xsl:variable name="stereotypeID" select="UML:ModelElement.stereotype/UML:Stereotype/attribute::xmi.idref" />
			
			<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" />
					<xsl:with-param name="package_y" select="$package_y" />									
				</xsl:call-template> 
			</xsl:variable>
	
			<xsl:comment>Dependency</xsl:comment>
			
			<!-- 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(#end_trans_arrowhead)</xsl:attribute>
			</path>         
			
			<xsl:if test="$name">
				<xsl:variable name="disX" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="disY" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]" />

				<text style="font-size:10px">
					<xsl:attribute name="x"><xsl:value-of select="$disX + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$disY + 11 + $package_y"/></xsl:attribute>
					<xsl:if test="$abstract = 'true'"><xsl:attribute name="font-style">oblique</xsl:attribute></xsl:if>                  
					<xsl:value-of select="$name"/>
				</text>                   
			</xsl:if>
			
			<!-- 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="dependencyPos_x" select="//UML:GraphEdge[descendant::UML:Dependency[attribute::xmi.idref=$dependencyID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="dependencyPos_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="$dependencyPos_x"/>
				<xsl:with-param name="object_y" select="$dependencyPos_y"/>
				<xsl:with-param name="package_x" select="$package_x"/>
				<xsl:with-param name="package_y" select="$package_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>			
		</xsl:if>	
	</xsl:template>
	
	
	<!--**************************************************
	       ** Die Darstellung der einzelnen Assoziationen **
	       ****************************************************-->  
	<xsl:template match="UML:Association">
		<xsl:param name="DiagramID" />		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" />
		<xsl:param name="pPackage_y" /> 
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="associationID" select="@xmi.id" />
		<xsl:variable name="name" select="@name" />
		<xsl:variable name="abstract" select="@isAbstract" />
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][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 + $shift_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_x"/></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 + $shift_y"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_y"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			
			<!-- Die ID des zugehörigen UML:GraphEdge -->
			<xsl:variable name="edgeID" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][descendant::UML:Association[attribute::xmi.idref=$associationID]]/attribute::xmi.id" />
	
			<!-- Die IDs der beiden Connectoren -->
			<xsl:variable name="connectorID_1" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][attribute::xmi.id=$edgeID]/UML:GraphEdge.anchor/UML:GraphConnector[position()=1]/attribute::xmi.idref" />
			<xsl:variable name="connectorID_2" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][attribute::xmi.id=$edgeID]/UML:GraphEdge.anchor/UML:GraphConnector[position()=2]/attribute::xmi.idref" />
				
			<xsl:variable name="connectorClassID_1" select="//UML:GraphNode[child::UML:GraphElement.anchorage/UML:GraphConnector[attribute::xmi.id=$connectorID_1]]/UML:GraphElement.semanticModel/*/*/UML:Class/attribute::xmi.idref" />
			<xsl:variable name="connectorClassID_2" select="//UML:GraphNode[child::UML:GraphElement.anchorage/UML:GraphConnector[attribute::xmi.id=$connectorID_2]]/UML:GraphElement.semanticModel/*/*/UML:Class/attribute::xmi.idref" />
				
			<xsl:variable name="associationEnd1ID" select="//UML:AssociationEnd[child::UML:AssociationEnd.participant/UML:Class[attribute::xmi.idref=$connectorClassID_1]]/attribute::xmi.id" />
			<xsl:variable name="associationEnd2ID" select="//UML:AssociationEnd[child::UML:AssociationEnd.participant/UML:Class[attribute::xmi.idref=$connectorClassID_2]]/attribute::xmi.id" />	
			
			<xsl:variable name="associationEnd1Agg" select="//UML:AssociationEnd[attribute::xmi.id=$associationEnd1ID]/attribute::aggregation" />
			<xsl:variable name="associationEnd2Agg" select="//UML:AssociationEnd[attribute::xmi.id=$associationEnd2ID]/attribute::aggregation" />        
			
			<xsl:variable name="associationEnd1Nav" select="//UML:AssociationEnd[attribute::xmi.id=$associationEnd1ID]/attribute::isNavigable" />
			<xsl:variable name="associationEnd2Nav" select="//UML:AssociationEnd[attribute::xmi.id=$associationEnd2ID]/attribute::isNavigable" />        	
			
			<xsl:variable name="associationEnd1QualifierID" select="UML:Association.connection/UML:AssociationEnd[position()=1]/UML:Classifier.feature/UML:Qualifier/attribute::xmi.id" />		
			<xsl:variable name="associationEnd2QualifierID" select="UML:Association.connection/UML:AssociationEnd[position()=2]/UML:Classifier.feature/UML:Qualifier/attribute::xmi.id" />		
	
			<xsl:variable name="associationEnd1QualifierName" select="UML:Association.connection/UML:AssociationEnd[position()=1]/UML:Classifier.feature/UML:Qualifier/attribute::name" />		
			<xsl:variable name="associationEnd2QualifierName" select="UML:Association.connection/UML:AssociationEnd[position()=2]/UML:Classifier.feature/UML:Qualifier/attribute::name" />		
			
			<xsl:variable name="associationPos_x" select="//UML:GraphEdge[descendant::UML:Association[attribute::xmi.idref=$associationID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="associationPos_y" select="//UML:GraphEdge[descendant::UML:Association[attribute::xmi.idref=$associationID]]/UML:GraphElement.position/XMI.field[position()=2]" />
			
			<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 + $associationPos_x" />
					<xsl:with-param name="package_y" select="$package_y + $associationPos_y" />			
				</xsl:call-template> 
			</xsl:variable>
			
			<xsl:comment>Association</xsl:comment>
			
			<!-- Die Connectoren sind ordered. D.h. der erste Connector ist dem ersten Waypoint des GraphEdge zugeordnet. Der 2. Connector dem letzten Waypoint. 
				Hier teste ich nun, welcher Connector der erste ist -->
			<xsl:variable name="connectorTest_1" select="//UML:GraphConnector[attribute::xmi.id=$connectorID_1][following::UML:GraphConnector[attribute::xmi.id=$connectorID_2]]" />		
			
			<!-- Der Pfeil -->
			<path stroke="black" fill="none"> 
				<xsl:attribute name="d">M<xsl:value-of select="substring-after($path,'L')"/></xsl:attribute>
				<xsl:choose>
					<xsl:when test="$associationEnd2Nav = $associationEnd1Nav"></xsl:when>
					<xsl:otherwise>
						<xsl:if test="$associationEnd1Nav = 'true'"><xsl:attribute name="marker-start">url(#start_trans_arrowhead)</xsl:attribute></xsl:if> 
						<xsl:if test="$associationEnd2Nav = 'true'"><xsl:attribute name="marker-end">url(#end_trans_arrowhead)</xsl:attribute></xsl:if>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:if test="$associationEnd1Agg = 'aggregate'"><xsl:attribute name="marker-start">url(#agg_arrowhead)</xsl:attribute></xsl:if>
				<xsl:if test="$associationEnd1Agg = 'composite'"><xsl:attribute name="marker-start">url(#com_arrowhead)</xsl:attribute></xsl:if>
				<xsl:if test="$associationEnd2Agg = 'aggregate'"><xsl:attribute name="marker-end">url(#agg_arrowhead)</xsl:attribute></xsl:if>
				<xsl:if test="$associationEnd2Agg = 'composite'"><xsl:attribute name="marker-end">url(#com_arrowhead)</xsl:attribute></xsl:if>
			</path>         
			
			<xsl:if test="$associationEnd1QualifierID">
				<xsl:variable name="associationEnd1_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd1ID]]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="associationEnd1_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd1ID]]/UML:GraphElement.position/XMI.field[position()=2]" />
	
				<xsl:variable name="qc_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd1ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='QualifierCompartment']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="qc_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd1ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='QualifierCompartment']]/UML:GraphElement.position/XMI.field[position()=2]" />
	
				<xsl:variable name="qc_width" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd1ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='QualifierCompartment']]/UML:GraphNode.size/XMI.field[position()=1]" />
				<xsl:variable name="qc_height" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd1ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='QualifierCompartment']]/UML:GraphNode.size/XMI.field[position()=2]" />
				
				<xsl:variable name="qualifier_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Qualifier[attribute::xmi.idref=$associationEnd1QualifierID]]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="qualifier_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Qualifier[attribute::xmi.idref=$associationEnd1QualifierID]]/UML:GraphElement.position/XMI.field[position()=2]" />
	
				<rect 	x="{$associationEnd1_x + $qualifier_x + $qc_x}" y="{$associationEnd1_y + $qc_y + $qualifier_y}"
					height="{$qc_height}"
					width="{$qc_width}"
					fill="white" stroke="black"
				/>	
				<text>
					<xsl:attribute name="x"><xsl:value-of select="$associationEnd1_x + $qualifier_x + $qc_x + $qualifier_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$associationEnd1_y + $qualifier_y + $qc_y + $qualifier_y + 12"/></xsl:attribute>
					<xsl:value-of select="$associationEnd1QualifierName"/>
				</text>			
			</xsl:if>
	
			<xsl:if test="$associationEnd2QualifierID">
				<xsl:variable name="associationEnd2_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd2ID]]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="associationEnd2_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd2ID]]/UML:GraphElement.position/XMI.field[position()=2]" />
	
				<xsl:variable name="qc_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd2ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='QualifierCompartment']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="qc_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd2ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='QualifierCompartment']]/UML:GraphElement.position/XMI.field[position()=2]" />
	
				<xsl:variable name="qc_width" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd2ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='QualifierCompartment']]/UML:GraphNode.size/XMI.field[position()=1]" />
				<xsl:variable name="qc_height" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEnd2ID]]/UML:GraphElement.contained/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='QualifierCompartment']]/UML:GraphNode.size/XMI.field[position()=2]" />
				
				<xsl:variable name="qualifier_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Qualifier[attribute::xmi.idref=$associationEnd2QualifierID]]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="qualifier_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Qualifier[attribute::xmi.idref=$associationEnd2QualifierID]]/UML:GraphElement.position/XMI.field[position()=2]" />
	
				<rect 	x="{$associationEnd2_x + $qc_x + $qualifier_x}" y="{$associationEnd2_y + $qc_y + $qualifier_y}"
					height="{$qc_height}"
					width="{$qc_width}"
					fill="white" stroke="black"
				/>
					
				<text>
					<xsl:attribute name="x"><xsl:value-of select="$associationEnd2_x + $qualifier_x + $qc_x + $qualifier_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$associationEnd2_y + $qualifier_y + $qc_y + $qualifier_y + 12"/></xsl:attribute>
					<xsl:value-of select="$associationEnd2QualifierName"/>
				</text>
				
			</xsl:if>
	
			<!-- Bezeichnung der Association -->
			<xsl:if test="$name">
				<xsl:variable name="disX" 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]" />
				<xsl:variable name="disY" 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]" />
				<xsl:text>            
				</xsl:text>              
				<text style="font-size:10px">
					<xsl:attribute name="x"><xsl:value-of select="$disX + $package_x + $associationPos_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$disY + 11 + $package_y + $associationPos_y"/></xsl:attribute>
					<xsl:if test="$abstract = 'true'"><xsl:attribute name="font-style">oblique</xsl:attribute></xsl:if>                  
					<xsl:value-of select="$name"/>
				</text>                   
			</xsl:if>
	
			<!-- 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" />
			
			<!-- stereotype -->
			<xsl:apply-templates select="UML:ModelElement.stereotype">
				<xsl:with-param name="object_x" select="$associationPos_x"/>
				<xsl:with-param name="object_y" select="$associationPos_y"/>
				<xsl:with-param name="package_x" select="$package_x"/>
				<xsl:with-param name="package_y" select="$package_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>
	
			<!-- AssociationEnd -->
			<xsl:apply-templates select="*/UML:AssociationEnd" mode="diagram">
				<xsl:with-param name="package_x" select="$package_x + $associationPos_x" />
				<xsl:with-param name="package_y" select="$package_y + $associationPos_y" />			
			</xsl:apply-templates>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="UML:AssociationEnd" mode="diagram">
		<xsl:param name="package_x" />
		<xsl:param name="package_y" />
		
		<xsl:variable name="associationEndName" select="@name" />
		<xsl:variable name="associationEndID" select="@xmi.id" />
		
		<xsl:variable name="associationEndAggregation" select="@aggregation" />
		<xsl:variable name="associationEndNavigable" select="@isNavigable" />
		
		<xsl:variable name="associationEnd_lower" select="UML:AssociationEnd.multiplicity/UML:Multiplicity/UML:Multiplicity.range/UML:MultiplicityRange/attribute::lower" />
		<xsl:variable name="associationEnd_upper" select="UML:AssociationEnd.multiplicity/UML:Multiplicity/UML:Multiplicity.range/UML:MultiplicityRange/attribute::upper" />

		<xsl:variable name="associationEnd_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEndID]]/UML:GraphElement.position/XMI.field[position()=1]" />
		<xsl:variable name="associationEnd_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEndID]]/UML:GraphElement.position/XMI.field[position()=2]" />

		<xsl:variable name="associationEndMultiplicity_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEndID]]//UML:GraphNode[descendant::UML:SimpleSemanticModelElement[attribute::typeInfo='Multiplicity']]/UML:GraphElement.position/XMI.field[position()=1]" />
		<xsl:variable name="associationEndMultiplicity_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEndID]]//UML:GraphNode[descendant::UML:SimpleSemanticModelElement[attribute::typeInfo='Multiplicity']]/UML:GraphElement.position/XMI.field[position()=2]" />

		<xsl:variable name="associationEndName_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEndID]]//UML:GraphNode[descendant::UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]" />
		<xsl:variable name="associationEndName_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEndID]]//UML:GraphNode[descendant::UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]" />
		
		<xsl:variable name="associationEndMultiplicityIsVisible" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEndID]]//UML:GraphNode[descendant::UML:SimpleSemanticModelElement[attribute::typeInfo='Multiplicity']]/attribute::isVisible" />
		<xsl:variable name="associationEndNameIsVisible" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:AssociationEnd[attribute::xmi.idref=$associationEndID]]//UML:GraphNode[descendant::UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/attribute::isVisible" />
	
		<xsl:if test="$associationEndMultiplicityIsVisible = 'true'">
			<text style="font-size:10px">
				<xsl:attribute name="x"><xsl:value-of select="$associationEndMultiplicity_x + $associationEnd_x + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$associationEndMultiplicity_y + $associationEnd_y + 11 + $package_y"/></xsl:attribute>               
		
				<xsl:call-template name="getMultiplicity">
					<xsl:with-param name="lower" select="$associationEnd_lower" />
					<xsl:with-param name="upper" select="$associationEnd_upper" />
				</xsl:call-template>
			</text>
		</xsl:if>

		<xsl:if test="$associationEndNameIsVisible = 'true'">
			<text style="font-size:10px">
				<xsl:attribute name="x"><xsl:value-of select="$associationEndName_x + $associationEnd_x + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$associationEndName_y + $associationEnd_y + 11 + $package_y"/></xsl:attribute>               
			
				<xsl:value-of select="$associationEndName"/>		
			</text>
		</xsl:if>
	</xsl:template>

   	<!-- ***** Nodes/Comments ***** -->
   	<xsl:template match="UML:Comment" mode="package">
		<xsl:param name="DiagramID" />		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" />
		<xsl:param name="pPackage_y" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />		
		
		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x + $shift_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_x"/></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 + $shift_y"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_y"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

   		<xsl:variable name="commentID" select="@xmi.id" />
   		<xsl:variable name="commentBody" select="@body" />
   		
   		<xsl:variable name="comment_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Comment[attribute::xmi.idref=$commentID]]/UML:GraphElement.position/XMI.field[1] + $package_x" />
   		<xsl:variable name="comment_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Comment[attribute::xmi.idref=$commentID]]/UML:GraphElement.position/XMI.field[2] + $package_y" />   	
   		
   		<xsl:variable name="commentWidth" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Comment[attribute::xmi.idref=$commentID]]/UML:GraphNode.size/XMI.field[1]" />
   		<xsl:variable name="commentHeight" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Comment[attribute::xmi.idref=$commentID]]/UML:GraphNode.size/XMI.field[2]" />   		
   		
   		<polygon stroke="black" fill="yellow" >
   			<xsl:attribute name="points">
   				<xsl:value-of select="$comment_x"/>,<xsl:value-of select="$comment_y"/><xsl:text> </xsl:text>
   				<xsl:value-of select="$comment_x"/>,<xsl:value-of select="$comment_y+$commentHeight"/><xsl:text> </xsl:text>
   				<xsl:value-of select="$comment_x+$commentWidth"/>,<xsl:value-of select="$comment_y+$commentHeight"/><xsl:text> </xsl:text>
   				<xsl:value-of select="$comment_x+$commentWidth"/>,<xsl:value-of select="$comment_y + 15"/><xsl:text> </xsl:text>
   				<xsl:value-of select="$comment_x+$commentWidth - 15"/>,<xsl:value-of select="$comment_y + 15"/><xsl:text> </xsl:text>   				
   				<xsl:value-of select="$comment_x+$commentWidth - 15"/>,<xsl:value-of select="$comment_y"/><xsl:text> </xsl:text>
   				<xsl:value-of select="$comment_x"/>,<xsl:value-of select="$comment_y"/><xsl:text> </xsl:text>
   			</xsl:attribute>
   		</polygon>			   		
      	
	      	<polygon stroke="black" fill="yellow" >
	   		<xsl:attribute name="points">
	   			<xsl:value-of select="$comment_x+$commentWidth - 15"/>,<xsl:value-of select="$comment_y + 15"/><xsl:text> </xsl:text>   				
	   			<xsl:value-of select="$comment_x+$commentWidth - 15"/>,<xsl:value-of select="$comment_y"/><xsl:text> </xsl:text>
	   			<xsl:value-of select="$comment_x+$commentWidth"/>,<xsl:value-of select="$comment_y + 15"/><xsl:text> </xsl:text>
	   		</xsl:attribute>
	      	</polygon>			   	

		<text>
			<xsl:attribute name="x"><xsl:value-of select="$comment_x + 10"/></xsl:attribute>
			<xsl:attribute name="y"><xsl:value-of select="$comment_y + 5"/></xsl:attribute>
			
			<xsl:attribute name="style">
				<xsl:text>font-size:11px;</xsl:text>
			</xsl:attribute>

			<xsl:variable name="comment">
				<xsl:call-template name="parseComment">
					<xsl:with-param name="text" select="concat($commentBody,'&#10;')" />
					<xsl:with-param name="object_x" select="$comment_x + 10" />
				</xsl:call-template>				
			</xsl:variable>
			
			<xsl:copy-of select="$comment" />
		</text>
		
		<xsl:variable name="commentLinkGraphEdgeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Comment[attribute::xmi.idref=$commentID]]/UML:GraphElement.anchorage/*/*/UML:GraphEdge/attribute::xmi.idref" />
		
		<xsl:if test="$commentLinkGraphEdgeID">
			<xsl:variable name="path">
				<xsl:call-template name="buildPath">
					<xsl:with-param name="waypoints" select="//UML:GraphEdge[attribute::xmi.id=$commentLinkGraphEdgeID]/UML:GraphEdge.waypoints/XMI.field" />
					<xsl:with-param name="pos" select="count(//UML:GraphEdge[attribute::xmi.id=$commentLinkGraphEdgeID]/UML:GraphEdge.waypoints/XMI.field) -1" />
					<xsl:with-param name="package_x" select="$package_x" />
					<xsl:with-param name="package_y" select="$package_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>
			</path>         
		</xsl:if>		
   	</xsl:template>
   
	<!-- ***** Die Darstellung der einzelnen Operationen ***** -->
	<xsl:template match="UML:Operation">		
		<xsl:param name="DiagramID" />		
		<xsl:param name="objectID" />
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" />
		<xsl:param name="pPackage_y" />

		<xsl:variable name="operationName" select="@name"/>
		<xsl:variable name="operationVisibility" select="@visibility" />
		<xsl:variable name="operationID" select="@xmi.id" />
		<xsl:variable name="ownerScope" select="@ownerScope" />		
		<xsl:variable name="isAbstract" select="@isAbstract" />

		<!-- 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:Operation[attribute::xmi.idref=$operationID]]/UML:GraphElement.position/XMI.field[position()=1]"/>

		<xsl:variable name="package_x">
			<xsl:value-of select="$pPackage_x" />			
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:value-of select="$pPackage_y"/>
		</xsl:variable>

		<xsl:if test="$control">
			<!-- Der return-Typ der Methode -->
			<xsl:variable name="dataTypeID" select="UML:BehavioralFeature.parameter/UML:Parameter[attribute::kind='return']/*/*/attribute::xmi.idref" />        
			<xsl:variable name="dataType" select="//*[attribute::xmi.id=$dataTypeID]/attribute::name" />
			
			<!-- x/y Werte fuer die Position der Klasse -->
			<xsl:variable name="pos_x" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$objectID]]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="pos_y" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$objectID]]/UML:GraphElement.position/XMI.field[position()=2]"/>
			
			<!-- x/y Werte fuer die Position des Methoden Bereichs (OperationCompartment) -->
			<xsl:variable name="ocPos_x" select="//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='OperationCompartment']][descendant::UML:Operation[attribute::xmi.idref=$operationID]]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="ocPos_y" select="//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='OperationCompartment']][descendant::UML:Operation[attribute::xmi.idref=$operationID]]/UML:GraphElement.position/XMI.field[position()=2]"/>
	
			<!-- x/y Werte fuer die Position der Methoden Koepfe. Relativ gesehen zur OperationCompoartment -->
			<xsl:variable name="operationNamePos_x" select="//UML:GraphNode[child::*/*/*/UML:Operation[attribute::xmi.idref=$operationID]]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="operationNamePos_y" select="//UML:GraphNode[child::*/*/*/UML:Operation[attribute::xmi.idref=$operationID]]/UML:GraphElement.position/XMI.field[position()=2]"/>
			
			<!-- Stereotype -->
			<xsl:variable name="stereotypeID" select="//UML:Classifier.feature/UML:Operation[attribute::xmi.id=$operationID]/UML:ModelElement.stereotype/UML:Stereotype/attribute::xmi.idref" />

			<!-- Is there a Stereotype Compartment (= a Stereotype was used), then find the id of corresponding GraphNode -->
			<xsl:variable name="stereotypeCompartmentGraphNodeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Operation[attribute::xmi.idref=$operationID]]/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
	
			<!-- stereotype -->
			<xsl:if test="$stereotypeCompartmentGraphNodeID != '' ">
				<xsl:apply-templates select="UML:ModelElement.stereotype">
					<xsl:with-param name="object_x" select="$pos_x + $operationNamePos_x + $ocPos_x"/>
					<xsl:with-param name="object_y" select="$pos_y + $operationNamePos_y + $ocPos_y"/>
					<xsl:with-param name="package_x" select="$package_x"/>
					<xsl:with-param name="package_y" select="$package_y"/>
					<xsl:with-param name="graphNodeID" select="$stereotypeCompartmentGraphNodeID"/>
				</xsl:apply-templates>
			</xsl:if>
			
			<xsl:comment>Methoden</xsl:comment>
			
			<!--  Darstellung der Methode -->
			<xsl:text>        </xsl:text>        
			<text y="{$operationNamePos_y + $pos_y + $ocPos_y + 11 + $package_y}">
				<xsl:choose>
					<xsl:when test="$stereotypeCompartmentGraphNodeID">
						<xsl:variable name="stereotypeCompartment_width" select="//UML:GraphNode[attribute::xmi.id=$stereotypeCompartmentGraphNodeID]/UML:GraphNode.size/XMI.field[1]" />
						<xsl:attribute name="x"><xsl:value-of select="$ocPos_x + $operationNamePos_x + $pos_x + $package_x + $stereotypeCompartment_width"/></xsl:attribute>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="x"><xsl:value-of select="$ocPos_x + $operationNamePos_x + $pos_x + $package_x"/></xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>
				
				<xsl:attribute name="style">
					<xsl:text>font-size:11px;</xsl:text>
					<xsl:if test="$ownerScope = 'classifier'">text-decoration:underline;</xsl:if> <!-- static -->
					<xsl:if test="$isAbstract = 'true'">font-style:oblique</xsl:if> <!-- abstract -->
				</xsl:attribute>
			
				<!-- Sichtbarkeit der Methode (public, private, ...) -->
				<xsl:call-template name="getVisibility">
					<xsl:with-param name="visibility" select="$operationVisibility" />
				</xsl:call-template>
				
				<!-- Name, Parameter, Returnwert -->
				<xsl:value-of select="$operationName"/>(<xsl:call-template name="parameters"><xsl:with-param name="operationID" select="$operationID" /></xsl:call-template>):<xsl:value-of select="$dataType"/> 
			</text>
		</xsl:if>
	</xsl:template>

	<!-- *******************************************
	        ** Die Darstellung der einzelnen Attribute **
	        ******************************************* -->    
	<xsl:template match="UML:Attribute">
		<xsl:param name="DiagramID" />		
		<xsl:param name="objectID" />
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" />
		<xsl:param name="pPackage_y" /> 

		<xsl:variable name="attName" select="@name"/>
		<xsl:variable name="attVisibility" select="@visibility" />
		<xsl:variable name="ownerScope" select="@ownerScope" />
		<xsl:variable name="attID" select="@xmi.id" />
		
		<!-- 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:Attribute[attribute::xmi.idref=$attID]]/UML:GraphElement.position/XMI.field[position()=1]"/>
	
		<xsl:variable name="package_x">
			<xsl:value-of select="$pPackage_x"/>
		</xsl:variable>

		<xsl:variable name="package_y">
			<xsl:value-of select="$pPackage_y"/>
		</xsl:variable>

		<xsl:if test="$control">
			
			<!-- Type of Attribute -->
			<xsl:variable name="dataTypeID" select="descendant::*/attribute::xmi.idref" />        
			<xsl:variable name="dataType" select="//*[attribute::xmi.id=$dataTypeID]/attribute::name" />
			
			<!-- Coordinates of corresponding Class -->
			<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$objectID]]/XMI.field[position()=1]"/>
			<xsl:variable name="pos_y" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$objectID]]/XMI.field[position()=2]"/>
			
			<!-- Coordinates of AttributeCompartment -->
			<xsl:variable name="acPos_y" select="//UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='AttributeCompartment']][descendant::UML:Attribute[attribute::xmi.idref=$attID]]/UML:GraphElement.position/XMI.field[position()=2]"/>
			
			<!-- x/y Values of Attribute. Relativ to AttributeCompartment -->
			<xsl:variable name="attNamePos_x" select="//UML:GraphNode[child::*/*/*/UML:Attribute[attribute::xmi.idref=$attID]]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="attNamePos_y" select="//UML:GraphNode[child::*/*/*/UML:Attribute[attribute::xmi.idref=$attID]]/UML:GraphElement.position/XMI.field[position()=2]"/>
			
			<!-- Startwert -->
			<xsl:variable name="initialValue" select="//UML:Classifier.feature/UML:Attribute[attribute::xmi.id=$attID]/UML:Attribute.initialValue/UML:Expression/attribute::body"></xsl:variable>
			
			<xsl:comment> Attribute </xsl:comment>

			<!-- Is there a Stereotype Compartment (= a Stereotype was used), then find the id of corresponding GraphNode -->
			<xsl:variable name="stereotypeCompartmentGraphNodeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Attribute[attribute::xmi.idref=$attID]]/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
	
			<!-- stereotype -->
			<xsl:if test="$stereotypeCompartmentGraphNodeID != '' ">
				<xsl:apply-templates select="UML:ModelElement.stereotype">
					<xsl:with-param name="object_x" select="$attNamePos_x + $pos_x"/>
					<xsl:with-param name="object_y" select="$attNamePos_y + $pos_y + $acPos_y "/>
					<xsl:with-param name="package_x" select="$package_x"/>
					<xsl:with-param name="package_y" select="$package_y"/>
					<xsl:with-param name="graphNodeID" select="$stereotypeCompartmentGraphNodeID"/>			
				</xsl:apply-templates>
			</xsl:if>
			
			<!-- Das Textelement in SVG -->
			<text>
				<xsl:choose>
					<xsl:when test="$stereotypeCompartmentGraphNodeID">
						<xsl:variable name="stereotypeCompartment_width" select="//UML:GraphNode[attribute::xmi.id=$stereotypeCompartmentGraphNodeID]/UML:GraphNode.size/XMI.field[1]" />
						<xsl:attribute name="x"><xsl:value-of select="$attNamePos_x + $pos_x + $package_x + $stereotypeCompartment_width"/></xsl:attribute>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="x"><xsl:value-of select="$attNamePos_x + $pos_x + $package_x"/></xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>
				
				<xsl:attribute name="y"><xsl:value-of select="$attNamePos_y + $pos_y + $acPos_y  +12+ $package_y"/></xsl:attribute>
				<xsl:attribute name="style">
					<xsl:text>font-size:11px;</xsl:text>
					<xsl:if test="$ownerScope = 'classifier'">text-decoration:underline</xsl:if>
				</xsl:attribute>
			
				<!-- Sichtbarkeit -->
				<xsl:call-template name="getVisibility">
					<xsl:with-param name="visibility" select="$attVisibility" />
				</xsl:call-template>          
				
				<xsl:value-of select="$attName"/>:<xsl:value-of select="$dataType"/>           
				
				<!-- Multiplicities -->
				<xsl:variable name="lower" select="//UML:Classifier.feature/UML:Attribute[attribute::xmi.id=$attID]/UML:StructuralFeature.multiplicity//UML:MultiplicityRange/attribute::lower" />
				<xsl:variable name="upper" select="//UML:Classifier.feature/UML:Attribute[attribute::xmi.id=$attID]/UML:StructuralFeature.multiplicity//UML:MultiplicityRange/attribute::upper" />            
				
				<xsl:call-template name="getMultiplicity">
					<xsl:with-param name="lower" select="$lower" />
					<xsl:with-param name="upper" select="$upper" />
				</xsl:call-template>
				
				<!-- Vorgabewert -->
				<xsl:if test="$initialValue != '' ">=<xsl:value-of select="$initialValue"/></xsl:if>	
			</text>
		</xsl:if>		
	</xsl:template>
    
	<!-- ***************************************************************
	        ** Die Darstellung der einzelnen Interface (Rechteck und Name) **
	        *************************************************************** -->    
	<xsl:template match="UML:Interface">
		<xsl:param name="DiagramID" />		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" />
		<xsl:param name="pPackage_y" /> 
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="interfaceID" select="@xmi.id" />
		<xsl:variable name="interfaceName" select="@name" />
		<xsl:variable name="isAbstract" select="@isAbstract" />
		<xsl:variable name="visibility" select="@visibility" />
		
		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x + $shift_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_x"/></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 + $shift_y"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_y"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->		
		<xsl:variable name="control" select="//UML:GraphNode[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]]/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/XMI.field[position()=1]"/>

		<xsl:if test="$control">

			<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/XMI.field[position()=1]"/>
			<xsl:variable name="pos_y" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/XMI.field[position()=2]"/>
			
		
			<xsl:comment>**************** Interface <xsl:value-of select="$interfaceName"/> ****************</xsl:comment>
			
			<!-- Die Umrandung der Klasse -->
			<xsl:text>        </xsl:text>
			<rect 	x="{$pos_x + $package_x}" y="{$pos_y + $package_y}"
				height="{//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/XMI.field[position()=2]}"
				width="{//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/XMI.field[position()=1]}"
				fill="white" stroke="black"
			/>
			
			<!-- X und Y Werte fuer den Namen -->
			<xsl:variable name="namePos_x" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="namePos_y" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]"/>
			
			<!-- Is there a Stereotype Compartment (= a Stereotype was used), then find the id of corresponding GraphNode -->
			<xsl:variable name="stereotypeCompartmentGraphNodeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/*/*/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
	
			<!-- stereotype -->
			<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="$package_x"/>
				<xsl:with-param name="package_y" select="$package_y"/>
				<xsl:with-param name="graphNodeID" select="$stereotypeCompartmentGraphNodeID"/>			
			</xsl:apply-templates>
			
			<xsl:comment>Name des Interfaces</xsl:comment>
			<text> 
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12 + $package_y"/></xsl:attribute>
				<xsl:attribute name="style">
					<xsl:text>font-size:11px; font-weight:bold;</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 + $pos_x + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12 + $package_y"/></xsl:attribute>        
					<xsl:value-of select="$interfaceName"/>               
				</tspan>             
			</text>    
			
			<xsl:variable name="isVisible" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/attribute::isVisible" />

			<xsl:if test="$isVisible = 'true' ">	
				<!-- Sichtbarkeit -->
				<xsl:variable name="visPos_x" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/UML:GraphElement.position/XMI.field[position()=1]"/>
				<xsl:variable name="visPos_y" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$interfaceID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/UML:GraphElement.position/XMI.field[position()=2]"/>
	
				<text>
					<xsl:attribute name="x"><xsl:value-of select="$visPos_x + $pos_x + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$visPos_y  + $pos_y +12 + $package_y"/></xsl:attribute>
					
					<xsl:call-template name="getVisibility">
						<xsl:with-param name="visibility" select="$visibility" />
					</xsl:call-template>	
				</text>	
			</xsl:if>
			
			<!-- Trenner Attribute/Operation Compartment -->
			<xsl:variable name="sepPos_y" select="//UML:GraphNode[descendant::UML:Interface[attribute::xmi.idref=$interfaceID]]//UML:GraphNode[descendant::UML:SimpleSemanticModelElement[attribute::typeInfo='CompartmentSeparator']]/UML:GraphElement.position/XMI.field[position()=2]" />
			<xsl:variable name="sepSize" select="//UML:GraphNode[child::UML:GraphElement.semanticModel/*/*/UML:Interface[attribute::xmi.idref=$interfaceID]]/UML:GraphNode.size/XMI.field[position()=1]"></xsl:variable>
			
			<xsl:comment>Name/Operation Separator</xsl:comment>
			
			<line x1="{$pos_x + 1 + $package_x}" x2="{$pos_x + $sepSize + $package_x}" y1="{$pos_y + $sepPos_y + $package_y}" y2="{$pos_y + $sepPos_y  + $package_y}" style="stroke:black;stroke-width=5"/>
	
			<xsl:apply-templates select="*/UML:Attribute">
				<xsl:with-param name="objectID" select="$interfaceID" />
				<xsl:with-param name="DiagramID" select="$DiagramID" />				
				<xsl:with-param name="packageID" select="$packageID" />
				<xsl:with-param name="pPackage_x" select="$package_x" />
				<xsl:with-param name="pPackage_y" select="$package_y" />
			</xsl:apply-templates>
			
			<xsl:apply-templates select="*/UML:Operation">
				<xsl:with-param name="objectID" select="$interfaceID" />
				<xsl:with-param name="DiagramID" select="$DiagramID" />				
				<xsl:with-param name="packageID" select="$packageID" />
				<xsl:with-param name="pPackage_x" select="$package_x" />
				<xsl:with-param name="pPackage_y" select="$package_y" />
			</xsl:apply-templates>
		
		</xsl:if>
	</xsl:template>

	<!-- ***************************************************************
	        ** Die Darstellung der einzelnen Klassen (Rechteck und Name) **
	        *************************************************************** -->  
	<xsl:template match="UML:Class">
		<xsl:param name="DiagramID" />		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" />
		<xsl:param name="pPackage_y" />
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="classID" select="@xmi.id" />
		<xsl:variable name="className" select="@name" />
		<xsl:variable name="isAbstract" select="@isAbstract" />
		<xsl:variable name="visibility" select="@visibility" />
		
		<!-- 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=$classID]]/UML:GraphElement.position/XMI.field[position()=1]"/>

		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x + $shift_x"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_x"/></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 + $shift_y"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_y"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			
			<!-- X/Y Koordinate der linken, oberen Ecke -->
			<xsl:variable name="pos_x" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/XMI.field[position()=1]"/>
			<xsl:variable name="pos_y" select="//UML:GraphNode/UML:GraphElement.position[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/XMI.field[position()=2]"/>
			
			<xsl:comment> **************** Klasse <xsl:value-of select="$className"/> ****************</xsl:comment>
			
			<!-- Die Umrandung der Klasse -->
			<xsl:text>        </xsl:text>
			<rect 	x="{$pos_x + $package_x}" y="{$pos_y  + $package_y}"
				height="{//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/XMI.field[position()=2]}"
				width="{//UML:GraphNode/UML:GraphNode.size[following-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/XMI.field[position()=1]}"
				fill="white" stroke="black"
			/>
			
			<!-- X/Y Werte fuer den Namen -->
			<xsl:variable name="namePos_x" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]"/>
			<xsl:variable name="namePos_y" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]"/>
	
			
			<xsl:comment>Name of Class</xsl:comment>
			<text> 
				<xsl:attribute name="x"><xsl:value-of select="$namePos_x + $pos_x  + $package_x"/></xsl:attribute>
				<xsl:attribute name="y"><xsl:value-of select="$namePos_y + $pos_y + 12  + $package_y"/></xsl:attribute>
				<xsl:attribute name="style"><!-- Schriftart, -dicke und evtl. Kursivdruck (wenn Klasse abstract) -->
					<xsl:text>font-size:11px; font-weight:bold;</xsl:text>
					<xsl:if test="$isAbstract = 'true'">font-style:oblique</xsl:if>
				</xsl:attribute>         
				
				<xsl:value-of select="$className"/>               
			</text>    
			
			<xsl:variable name="isVisible" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/attribute::isVisible" />

			<xsl:if test="$isVisible = 'true'">
				<!-- X/Y Pos für die Visibility einer Klasse -->			
				<xsl:variable name="visPos_x" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/UML:GraphElement.position/XMI.field[position()=1]"/>
				<xsl:variable name="visPos_y" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/*/UML:GraphElement.contained/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Visibility']]/UML:GraphElement.position/XMI.field[position()=2]"/>
			
				<text>
					<xsl:attribute name="x"><xsl:value-of select="$visPos_x + $pos_x + $package_x"/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$visPos_y  + $pos_y +12 + $package_y"/></xsl:attribute>
					
					<xsl:call-template name="getVisibility">
						<xsl:with-param name="visibility" select="$visibility" />
					</xsl:call-template>	
				</text>	
			</xsl:if>
			
			<!-- Trenner Name/Attribute Compartment -->
			<xsl:variable name="linePos_y" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/UML:GraphNode[following-sibling::UML:GraphNode//UML:SimpleSemanticModelElement[attribute::typeInfo='AttributeCompartment']]/UML:GraphElement.position[following-sibling::*/UML:SimpleSemanticModelElement[attribute::typeInfo='CompartmentSeparator']]/XMI.field[position()=2]"/>
			<xsl:variable name="lineSize" select="//UML:GraphNode/UML:GraphElement.contained[preceding-sibling::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/UML:GraphNode[following-sibling::UML:GraphNode//UML:SimpleSemanticModelElement[attribute::typeInfo='AttributeCompartment']]/UML:GraphNode.size[following-sibling::*/UML:SimpleSemanticModelElement[attribute::typeInfo='CompartmentSeparator']]/XMI.field[position()=1]"/>
			
			<xsl:comment>Name/Attribute Separator</xsl:comment>
			<line x1="{$pos_x + 1 + $package_x}" x2="{$pos_x + $lineSize + $package_x}" y1="{$pos_y + $linePos_y + $package_y}" y2="{$pos_y + $linePos_y + $package_y}" style="stroke:black;stroke-width=5"/>
			
			<!-- Trenner Attribute/Operation Compartment -->
			<xsl:variable name="sepPos_y" select="//UML:GraphNode[descendant::*[attribute::xmi.idref=$classID]]//UML:GraphNode[following-sibling::UML:GraphNode//UML:SimpleSemanticModelElement[attribute::typeInfo='OperationCompartment']][preceding-sibling::UML:GraphNode//UML:SimpleSemanticModelElement[attribute::typeInfo='AttributeCompartment']][preceding::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/UML:GraphElement.position/XMI.field[position()=2]" />
			<xsl:variable name="sepSize" select="//UML:GraphNode[descendant::*[attribute::xmi.idref=$classID]]//UML:GraphNode[following-sibling::UML:GraphNode//UML:SimpleSemanticModelElement[attribute::typeInfo='OperationCompartment']][preceding-sibling::UML:GraphNode//UML:SimpleSemanticModelElement[attribute::typeInfo='AttributeCompartment']][preceding::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/UML:GraphNode.size/XMI.field[position()=1]" />
			
			<xsl:comment> Attribute/Operation Separator </xsl:comment>
	
			<line x1="{$pos_x + $package_x + 1}" x2="{$pos_x + $sepSize + $package_x}" y1="{$pos_y + $sepPos_y + $package_y}" y2="{$pos_y + $sepPos_y + $package_y}" style="stroke:black;stroke-width=5"/>
	
			<!-- ID of GraphNode -->
			<xsl:variable name="stereotypeGraphNodeID" select="//UML:GraphNode[child::UML:GraphElement.semanticModel//*[attribute::xmi.idref=$classID]]/*/*/*/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="$package_x"/>
				<xsl:with-param name="package_y" select="$package_y"/>
				<xsl:with-param name="graphNodeID" select="$stereotypeGraphNodeID"/>
			</xsl:apply-templates>
	
			<xsl:apply-templates select="*/UML:Attribute">
				<xsl:with-param name="objectID" select="$classID" />
				<xsl:with-param name="DiagramID" select="$DiagramID" />				
				<xsl:with-param name="packageID" select="$packageID" />
				<xsl:with-param name="pPackage_x" select="$package_x" />
				<xsl:with-param name="pPackage_y" select="$package_y" />
			</xsl:apply-templates>
			
			<xsl:apply-templates select="*/UML:Operation">
				<xsl:with-param name="objectID" select="$classID" />
				<xsl:with-param name="DiagramID" select="$DiagramID" />				
				<xsl:with-param name="packageID" select="$packageID" />
				<xsl:with-param name="pPackage_x" select="$package_x" />
				<xsl:with-param name="pPackage_y" select="$package_y" />
			</xsl:apply-templates>
		</xsl:if>
	</xsl:template>

	<!--**************************************************
	    ** Die Darstellung der einzelnen Generalisierungen **
	    ****************************************************-->  
	<xsl:template match="UML:Generalization">
		<xsl:param name="DiagramID" />		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" />
		<xsl:param name="pPackage_y" /> 
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="generalizationID" select="@xmi.id" />
		<xsl:variable name="discriminator" select="@discriminator" />
		<xsl:variable name="abstract" select="@isAbstract" />
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][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 + $shift_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_x"/></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 + $shift_y"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_y"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$control">
			<!-- Stereotype -->
			<xsl:variable name="stereotypeID" select="UML:ModelElement.stereotype/UML:Stereotype/attribute::xmi.idref" />
			
			<xsl:comment>Generalisierung</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" />
						<xsl:with-param name="package_y" select="$package_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"/></xsl:attribute>
						<xsl:attribute name="y"><xsl:value-of select="$disY + 11 + $package_y"/></xsl:attribute>
						<xsl:if test="$abstract = 'true'"><xsl:attribute name="font-style">oblique</xsl:attribute></xsl:if>
						<xsl:value-of select="$discriminator"/>
					</text>                   
				</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="generalizationPos_x" select="//UML:GraphEdge[descendant::UML:Generalization[attribute::xmi.idref=$generalizationID]]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="generalizationPos_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="$generalizationPos_x"/>
					<xsl:with-param name="object_y" select="$generalizationPos_y"/>
					<xsl:with-param name="package_x" select="$package_x"/>
					<xsl:with-param name="package_y" select="$package_y"/>
					<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
				</xsl:apply-templates>
				
			</xsl:if>
		</xsl:if>	
	</xsl:template>
		
	<!--**********************************************
  	       ** Die Darstellung der einzelnen Abstractions **
	       **********************************************-->  
	<xsl:template match="UML:Abstraction">
		<xsl:param name="DiagramID" />		
		<xsl:param name="packageID" />
		<xsl:param name="pPackage_x" />
		<xsl:param name="pPackage_y" /> 
		<xsl:param name="shift_x" />
		<xsl:param name="shift_y" />
		
		<xsl:variable name="abstractionID" select="@xmi.id" />
		<xsl:variable name="name" select="@name" />
		<xsl:variable name="abstract" select="@isAbstract" />
		
		<!-- Kontrolle ob überhaupt eine grafische Repräsentation der Variable existiert -->				
		<xsl:variable name="control" select="//UML:GraphEdge[ancestor::UML:Diagram[attribute::xmi.id=$DiagramID]][descendant::UML:Abstraction[attribute::xmi.idref=$abstractionID]]/UML:GraphEdge.waypoints/XMI.field" />
		
		<xsl:variable name="package_x">
			<xsl:choose>
				<xsl:when test="$packageID">
					<xsl:value-of select="$pPackage_x + $shift_x"/>				
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_x"/></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 + $shift_y"/>
				</xsl:when>
				<xsl:otherwise><xsl:value-of select="$shift_y"/></xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		
		<xsl:if test="$control">
			<!-- Stereotype -->
			<xsl:variable name="stereotypeID" select="UML:ModelElement.stereotype/UML:Stereotype/attribute::xmi.idref" />	
			
			<xsl:variable name="path">
				<xsl:call-template name="buildPath">
					<xsl:with-param name="waypoints" select="//UML:GraphEdge[descendant::UML:Abstraction[attribute::xmi.idref=$abstractionID]]/UML:GraphEdge.waypoints/XMI.field" />
					<xsl:with-param name="pos" select="count(//UML:GraphEdge[descendant::UML:Abstraction[attribute::xmi.idref=$abstractionID]]/UML:GraphEdge.waypoints/XMI.field) -1" />
					<xsl:with-param name="package_x" select="$package_x" />
					<xsl:with-param name="package_y" select="$package_y" />							
				</xsl:call-template> 
			</xsl:variable>
		
			<xsl:comment>Abstraction</xsl:comment>
			
			<!-- 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(#gen_arrowhead)</xsl:attribute>
			</path>         
			
			<xsl:if test="$name">
				<xsl:variable name="disX" select="//UML:GraphEdge[descendant::UML:Abstraction[attribute::xmi.idref=$abstractionID]]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=1]" />
				<xsl:variable name="disY" select="//UML:GraphEdge[descendant::UML:Abstraction[attribute::xmi.idref=$abstractionID]]/*/UML:GraphNode[child::*/UML:SimpleSemanticModelElement[attribute::typeInfo='Name']]/UML:GraphElement.position/XMI.field[position()=2]" />
				
				<text style="font-size:10px">
					<xsl:attribute name="x"><xsl:value-of select="$disX + $package_x "/></xsl:attribute>
					<xsl:attribute name="y"><xsl:value-of select="$disY + 11 + $package_y"/></xsl:attribute>
					<xsl:if test="$abstract = 'true'"><xsl:attribute name="font-style">oblique</xsl:attribute></xsl:if>                  
					<xsl:value-of select="$name"/>
				</text>                   
			</xsl:if>
			
			<!-- ID of GraphNode -->
			<xsl:variable name="graphNodeID" select="//UML:GraphEdge[child::UML:GraphElement.semanticModel/*/*/UML:Abstraction[attribute::xmi.idref=$abstractionID]]/*/UML:GraphNode[child::UML:GraphElement.semanticModel/*[attribute::typeInfo='StereotypeCompartment']]/attribute::xmi.id" />
			<xsl:variable name="abstractionPos_x" select="//UML:GraphEdge[descendant::UML:Abstraction[attribute::xmi.idref=$abstractionID]]/UML:GraphElement.position/XMI.field[position()=1]" />
			<xsl:variable name="abstractionPos_y" select="//UML:GraphEdge[descendant::UML:Abstraction[attribute::xmi.idref=$abstractionID]]/UML:GraphElement.position/XMI.field[position()=2]" />
			
			<!-- stereotype -->
			<xsl:apply-templates select="UML:ModelElement.stereotype">
				<xsl:with-param name="object_x" select="$abstractionPos_x"/>
				<xsl:with-param name="object_y" select="$abstractionPos_y"/>
				<xsl:with-param name="package_x" select="$package_x"/>
				<xsl:with-param name="package_y" select="$package_y"/>
				<xsl:with-param name="graphNodeID" select="$graphNodeID"/>			
			</xsl:apply-templates>		
		</xsl:if>	
	</xsl:template>

	<!-- baut aus lower/upper die richtige Multiplizität auf -->
	<xsl:template name="getMultiplicity">
		<xsl:param name="lower" />
		<xsl:param name="upper" />        
		<xsl:choose>
			<xsl:when test="$lower = $upper"><xsl:value-of select="$lower"/></xsl:when>
			<xsl:when test="$lower = '0' ">
				<xsl:if test="$upper = '1' ">0..1</xsl:if>
				<xsl:if test="$upper = '-1'">*</xsl:if>
			</xsl:when>
			<xsl:when test="$lower = '1'">
				<xsl:if test="$upper = '-1'">1..*</xsl:if>
			</xsl:when>
		</xsl:choose>          
	</xsl:template>

	<!-- Die einzelnen Parameter einer Methode werden hier abgearbeitet -->
	<xsl:template name="parameters">
		<xsl:param name="operationID" />               
		<xsl:for-each select="//UML:Operation[attribute::xmi.id=$operationID]/*/UML:Parameter[attribute::kind!='return']">
			<xsl:variable name="dataTypeID" select="UML:Parameter.type/UML:DataType/attribute::xmi.idref" />        
			<xsl:variable name="dataType" select="//UML:Package/UML:Namespace.ownedElement/UML:DataType[attribute::xmi.id=$dataTypeID]/attribute::name" />
			<xsl:value-of select="@name"/>:<xsl:value-of select="$dataType"/>            
		</xsl:for-each>        
	</xsl:template>	

	<!-- baut mehrzeilige Kommentare auf -->
	<xsl:template name="parseComment">
		<!-- der Kommentar der bearbeitet werden soll. Zeilenumbrüche werden durch &#10; dargestellt -->
		<xsl:param name="text" />
		<xsl:param name="object_x" />
		 
		<xsl:choose>
			<!-- Wenn der String mit einem Zeilenumbruch beginnt, eine Leerzeile einfügen -->
			<xsl:when test="starts-with($text,'&#10;') ">
				<!-- Template rekursiv aufrufen -->
				<xsl:call-template name="parseComment">
					<!-- Nachfolgenden Text abarbeiten -->
					<xsl:with-param name="text" select="substring-after($text,'&#10;')" />
					<xsl:with-param name="object_x" select="$object_x" />
				</xsl:call-template>		
				<!-- Neues tspan Element erzeugen -->
				<xsl:element name="tspan">
					<xsl:attribute name="dy">20</xsl:attribute>
					<xsl:attribute name="x"><xsl:value-of select="$object_x"/></xsl:attribute>	
				</xsl:element>			
			</xsl:when>
			
			<!-- Wenn es vor einem Zeilenumbruch noch Text gibt, dann weiter machen -->
			<xsl:when test="substring-before($text,'&#10;')">
				<!-- Der Text der aktuellen Zeile (alles vor einem Zeilenumbruch -->
				<xsl:variable name="substring" select="substring-before($text,'&#10;')" />

				<!-- neues tspan Element -->
				<xsl:element name="tspan">
					<xsl:attribute name="dy">20</xsl:attribute>
					<xsl:attribute name="x"><xsl:value-of select="$object_x"/></xsl:attribute>	
					<xsl:value-of select="$substring"/>					
				</xsl:element>			

				<!-- rekursiv aufrufen -->
				<xsl:call-template name="parseComment">
					<!-- Der Rest des Strings, nach der aktuellen Zeile -->
					<xsl:with-param name="text" select="substring-after($text,'&#10;')" />
					<xsl:with-param name="object_x" select="$object_x" />					
				</xsl:call-template>				
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
</xsl:stylesheet>

