<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:UML="omg.org/UML1.3">
<xsl:output indent="yes"/>

	<xsl:template match="/">

		<package>

			<xsl:attribute name="author">
			<xsl:text>SCTR Group</xsl:text>
			</xsl:attribute>
			<xsl:attribute name="name">
				<xsl:value-of select="XMI/XMI.content/UML:Diagram/@name"/>
			</xsl:attribute>
			<xsl:attribute name="version">1.0</xsl:attribute>
						
			<description>			 
				<xsl:attribute name="type">description</xsl:attribute><xsl:text>This is the basic Choreography description for a </xsl:text>
				<xsl:value-of select="XMI/XMI.content/UML:Diagram/@name"/><xsl:text>system</xsl:text>
			</description>
			<xsl:comment>Declaracion de tipos</xsl:comment>
			 <xsl:call-template name="information_type"/>

			<!--Los roles van a ser las clases y los actores -->
			<xsl:comment>Declaracion de Tokens</xsl:comment>

			<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Actor">
				<xsl:call-template name="Token">
					<xsl:with-param name="nombre" select="@name"/>
				</xsl:call-template>
			</xsl:for-each>


			<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Collaboration/UML:Namespace.ownedElement/UML:ClassifierRole">
				<xsl:call-template name="Token">
					<xsl:with-param name="nombre" select="@name"/>
				</xsl:call-template>
			</xsl:for-each>
			
			<!--Añadir también la consulta de actores y roles clasificados en un diagrama generado por la herramienta propia-->
			<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor/Foundation.Core.ModelElement.name">
				<xsl:call-template name="Token">
					<xsl:with-param name="nombre" select="."/>
				</xsl:call-template>
			</xsl:for-each>
			
			<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole/Foundation.Core.ModelElement.name">
				<xsl:call-template name="Token">
					<xsl:with-param name="nombre" select="."/>
				</xsl:call-template>
			</xsl:for-each>


			<xsl:comment>Declaracion de roles</xsl:comment>

			<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Actor">
				<xsl:call-template name="roleType">
					<xsl:with-param name="nombre" select="@name"/>
				</xsl:call-template>
			</xsl:for-each>

			<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Collaboration/UML:Namespace.ownedElement/UML:ClassifierRole">
				<xsl:call-template name="roleType">
					<xsl:with-param name="nombre" select="@name"/>
				</xsl:call-template>
			</xsl:for-each>
			
			<!--Añadir también la consulta de actores y roles clasificados en un diagrama generado por la herramienta propia-->
			<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor/Foundation.Core.ModelElement.name">
				<xsl:call-template name="roleType">
					<xsl:with-param name="nombre" select="."/>
				</xsl:call-template>
			</xsl:for-each>
			
			<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole/Foundation.Core.ModelElement.name">
				<xsl:call-template name="roleType">
					<xsl:with-param name="nombre" select="."/>
				</xsl:call-template>
			</xsl:for-each>
			
			<xsl:comment>Declaracion de participants</xsl:comment>

			<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Actor">
				<xsl:call-template name="participantType">
					<xsl:with-param name="nombre" select="@name"/>
				</xsl:call-template>
			</xsl:for-each>

			<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Collaboration/UML:Namespace.ownedElement/UML:ClassifierRole">
				<xsl:call-template name="participantType">
					<xsl:with-param name="nombre" select="@name"/>
				</xsl:call-template>
			</xsl:for-each>
			
			<!--Añadir también la consulta de actores y roles clasificados en un diagrama generado por la herramienta propia-->
			<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor/Foundation.Core.ModelElement.name">
				<xsl:call-template name="participantType">
					<xsl:with-param name="nombre" select="."/>
				</xsl:call-template>
			</xsl:for-each>
			
			<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole/Foundation.Core.ModelElement.name">
				<xsl:call-template name="participantType">
					<xsl:with-param name="nombre" select="."/>
				</xsl:call-template>
			</xsl:for-each>
						
			<!--####################################################################-->
			<xsl:comment>Declaracion de las Relaciones que se establecen entre los distintos roles</xsl:comment>
              <relation>
			<xsl:call-template name="relationshipType"/>
			  </relation>

			<!--####################################################################-->

			<xsl:comment>Declaracion de los canales</xsl:comment>
			<xsl:call-template name="channelType"/>
						
			<!--#####################################################################-->
			
			<xsl:comment>Definicion de la Coreografia</xsl:comment>
			
			<choreography>
				<xsl:attribute name="name">Main</xsl:attribute>
				<xsl:attribute name="root">
					<xsl:text>true</xsl:text>
				</xsl:attribute>
				<description>
					<xsl:attribute name="type">description</xsl:attribute><xsl:text>This choreography performs the collaboration between </xsl:text>
					<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Actor">
						<xsl:value-of select="translate(@name,' .:','___')"/>,</xsl:for-each>
					<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Collaboration/UML:Namespace.ownedElement/UML:ClassifierRole">
						<xsl:if test="position()=last()">
							<xsl:value-of select="translate(@name,' .:','___')"/>
						</xsl:if>
						<xsl:if test="not(position()=last())">
							<xsl:value-of select="translate(@name,' .:','___')"/>,</xsl:if>
					</xsl:for-each>
					
					<!--Añadir también la consulta de actores y roles clasificados en un diagrama generado por la herramienta propia-->
					<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor/Foundation.Core.ModelElement.name">
						<xsl:value-of select="translate(.,' .:','___')"/>,						
					</xsl:for-each>
					
					<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole/Foundation.Core.ModelElement.name">
						<xsl:if test="position()=last()">
							<xsl:value-of select="translate(.,' .:','___')"/>
						</xsl:if>
						<xsl:if test="not(position()=last())">
							<xsl:value-of select="translate(.,' .:','___')"/>,</xsl:if>
					</xsl:for-each>
					
				</description>
				<xsl:comment>Definicion de relationship</xsl:comment>
        
				<xsl:for-each select="XMI/XMI.content/UML:Model/UML:Namespace.ownedElement/UML:Package/UML:Namespace.ownedElement/UML:Collaboration/UML:Collaboration.interaction/UML:Interaction/UML:Interaction.message/UML:Message">
					<relationship>
						<xsl:attribute name="type">
							<xsl:for-each select="UML:ModelElement.taggedValue/UML:TaggedValue">

								<xsl:if test="@tag='ea_sourceName'">
									<xsl:value-of select="translate(@value,' .:','___')"/>
								</xsl:if>

								<xsl:if test="@tag='ea_targetName'">
									<xsl:value-of select="translate(@value,' .:','___')"/>
								</xsl:if>
							</xsl:for-each>
						</xsl:attribute>
					</relationship>
				</xsl:for-each>
				
				<!--Añadir también la consulta de mensajes generados por la herramienta propia-->
		
				<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.Collaborations/Behavioral_Elements.Collaborations.Collaboration.interaction/Behavioral_Elements.Collaborations.Message">		
				
					<!--Variables con los identificadores del origen y del destino-->
					<xsl:variable name="id_sour" select="Behavioral_Elements.Collaborations.Message.sender/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>
					
					<xsl:variable name="id_dest" select="Behavioral_Elements.Collaborations.Message.receiver/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>
					
					<relationship>
						<xsl:attribute name="type">
						
							<!--Escribir el origen y el destino del mensaje-->
							
							<!--Se debe tener en cuenta que pueden ser un actor o un rol-->
							
							<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]">
							
								<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
								
							</xsl:if>
							
							<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]">
							
								<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
								
							</xsl:if>
							
							<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
							
								<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
							
							</xsl:if>
							
							<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
							
								<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
								
							</xsl:if>
							
						</xsl:attribute>
					</relationship>
					
				</xsl:for-each>
	
				<!--##############################################################-->
				<xsl:comment>Declaracion de las variables</xsl:comment>
				<variableDefinitions>
					<xsl:call-template name="variableDefinitions"/>
				</variableDefinitions>
				
				<!--##############################################################-->
				<xsl:comment>Asignación de valores a las variables inicializadas con algún valor</xsl:comment>

				<xsl:call-template name="assign"/>
				
				<!--##############################################################-->
				<xsl:comment>Declaracion de las Interacciones</xsl:comment>
				<sequence>

				<xsl:call-template name="interaction"/>				
				
				</sequence>
				
			</choreography>
		</package>
	</xsl:template>
	<!--#################################################################################-->


	<!--A partir de aqui se declaran una serie de plantillas utilizadas para definir los diferentes elementos que componen un fichero wscdl-->
	
	<!--Plantilla creada para declarar los tipos-->
	<xsl:template name="information_type">	 	
	 			
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.Collaborations/Behavioral_Elements.Collaborations.Collaboration.interaction/Behavioral_Elements.Collaborations.Message">						
		
		<informationType>
			<xsl:if test="substring-before(Foundation.Core.ModelElement.name,'_') != ''">	
				<xsl:if test="substring-before(Foundation.Core.ModelElement.name,'_') != substring-before(preceding-sibling::*/Foundation.Core.ModelElement.name,'_')">									
				<!--Se le añade type al nombre del tipo si existe-->		
				<xsl:attribute name="name">
				 <xsl:value-of select="translate(substring-before(Foundation.Core.ModelElement.name,'_'),' .:','___')"/>
				 <xsl:text>Type</xsl:text>
				</xsl:attribute>
				<!--Se le añade tns: al nombre del tipo si existe-->
				<xsl:attribute name="type">
					<xsl:text>tns:</xsl:text>
				   <xsl:value-of select="translate(substring-before(Foundation.Core.ModelElement.name,'_'),' .:','___')"/>			
				</xsl:attribute>				
				</xsl:if>
			</xsl:if>
		</informationType>								
			
		</xsl:for-each>

	</xsl:template>
	
	<!--Plantilla creada para declarar los tokens-->
	<xsl:template name="Token">
		<xsl:param name="nombre"/>
		<token>
			<xsl:attribute name="name">
				<xsl:value-of select="translate($nombre,' .:','___')"/>Ref</xsl:attribute>
			<xsl:attribute name="informationType">StringType</xsl:attribute>
		</token>
	</xsl:template>	
	  
	<!--Plantilla creada para la definicion de los roles-->	
	<xsl:template name="roleType">

		<xsl:param name="nombre"/>

		<roleType>
			<xsl:attribute name="name">
				<xsl:value-of select="translate($nombre,' .:','___')"/>RoleType</xsl:attribute>			
			<behaviour>
				<xsl:attribute name="name">
					<xsl:value-of select="$nombre"/>Behaviour</xsl:attribute>
			</behaviour>
		</roleType>
	
	</xsl:template>
	
	<!--Plantilla creada para la definicion de los participants-->	
	<xsl:template name="participantType">

		<xsl:param name="nombre"/>

		<participantType>
			<xsl:attribute name="name">
				<xsl:value-of select="translate($nombre,' .:','___')"/></xsl:attribute>			
			<role>
				<xsl:attribute name="type">
					<xsl:value-of select="$nombre"/>RoleType</xsl:attribute>
			</role>
		</participantType>
	
	</xsl:template>
	
	<!--Plantilla creada para la definicion de los relationships-->
	<xsl:template name="relationshipType">
		
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.Collaborations/Behavioral_Elements.Collaborations.Collaboration.interaction/Behavioral_Elements.Collaborations.Message">		
					
			<!--Variables con los identificadores del origen y del destino-->
			<xsl:variable name="id_sour" select="Behavioral_Elements.Collaborations.Message.sender/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>
			
			<xsl:variable name="id_dest" select="Behavioral_Elements.Collaborations.Message.receiver/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>
					
			<relationship>			
							
				<xsl:attribute name="name">
				
					<!--Escribir el origen y el destino del mensaje-->
					
					<!--Se debe tener en cuenta que pueden ser un actor o un rol-->
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
					
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
									
				</xsl:attribute>
				
				<!--Escribir los roles origen y destino-->
				<role1>
					<xsl:attribute name="type">
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>RoleType</xsl:text>
						
					</xsl:attribute>
				</role1>
				
				<role2>
					<xsl:attribute name="type">
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
					
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>RoleType</xsl:text>
										
					</xsl:attribute>
				</role2>
				
			</relationship>
		</xsl:for-each>
			

	</xsl:template>
	
	<!--Plantilla creada para la definicion de los canales-->
	<xsl:template name="channelType">
		
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.Collaborations/Behavioral_Elements.Collaborations.Collaboration.interaction/Behavioral_Elements.Collaborations.Message">		
		
			<!--Variables con los identificadores del origen y del destino-->
			<xsl:variable name="id_sour" select="Behavioral_Elements.Collaborations.Message.sender/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>
			
			<xsl:variable name="id_dest" select="Behavioral_Elements.Collaborations.Message.receiver/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>
		
			<channelType>
				<xsl:attribute name="name">
					
					<!--Se debe tener en cuenta que pueden ser un actor o un rol-->
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>2</xsl:text>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
					
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>RoleType</xsl:text>
					
				</xsl:attribute>				

				<role>
				
					<xsl:attribute name="type">
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
					
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>RoleType</xsl:text>
					
					</xsl:attribute>
					
				</role>
				
				<reference>
					<token>
						<xsl:attribute name="name">
							<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
						</xsl:if>
						
						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
						
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
							
						</xsl:if>
						
						<xsl:text>Ref</xsl:text>
						</xsl:attribute>
					</token>
				</reference>
			</channelType>
								
		</xsl:for-each>
		
	</xsl:template>
	
	<!--Plantilla creada para la definicion de las variables-->
	<xsl:template name="variableDefinitions">
	
		<!--Declarar las variables de tipo Canal-->
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.Collaborations/Behavioral_Elements.Collaborations.Collaboration.interaction/Behavioral_Elements.Collaborations.Message">
			
			<!--Variables con los identificadores del origen y del destino-->
			<xsl:variable name="id_sour" select="Behavioral_Elements.Collaborations.Message.sender/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>
			
			<xsl:variable name="id_dest" select="Behavioral_Elements.Collaborations.Message.receiver/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>		
		
			<variable>
				<xsl:attribute name="name">
				
					<!--Se debe tener en cuenta que pueden ser un actor o un rol-->
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>2</xsl:text>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
					
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>Channel</xsl:text>
					
				</xsl:attribute>
				<xsl:attribute name="channelType">
				
					<!--Se debe tener en cuenta que pueden ser un actor o un rol-->
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>2</xsl:text>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
					
					</xsl:if>
					
					<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
					
						<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
					</xsl:if>
					
					<xsl:text>ChannelType</xsl:text>				
					
				</xsl:attribute>
			</variable>		
											
		</xsl:for-each>	
		
		<!--Declarar las variables asociadas a los actores-->
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor">
		
			<xsl:variable name="identificador" select="@xmi.id"/>
			<xsl:variable name="nombre" select="Foundation.Core.ModelElement.name"/>
			
			<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Variable']">

				<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
				
					<variable>
						<xsl:attribute name="name">
							<xsl:if test="not(contains(../Foundation.Extension_Mechanisms.TaggedValue.value,'='))">
								<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')"/>
							</xsl:if>
							<xsl:if test="contains(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')">
								<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/>
							</xsl:if>
						</xsl:attribute>
						<xsl:attribute name="informationType">
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='Clock'">
								<xsl:text>tns:</xsl:text>
								<xsl:value-of select="'Clock'"/>
							</xsl:if>
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='Integer'">
								<xsl:text>xsd:</xsl:text>
								<xsl:value-of select="'int'"/>
							</xsl:if>
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='Boolean'">
								<xsl:text>xsd:</xsl:text>
								<xsl:value-of select="'boolean'"/>
							</xsl:if>
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='String'">
								<xsl:text>xsd:</xsl:text>
								<xsl:value-of select="'string'"/>
							</xsl:if>
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='Exception'">
								<xsl:text>tns:</xsl:text>
								<xsl:value-of select="'exception'"/>
							</xsl:if>
						</xsl:attribute>
						<xsl:attribute name="roleTypes">
							<xsl:value-of select="$nombre"/>
						</xsl:attribute>						
					</variable>
				</xsl:if>
				
			</xsl:for-each>
						
		</xsl:for-each>
		
		<!--Declarar las variables asociadas a los lifeline-->
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole">
		
			<xsl:variable name="identificador" select="@xmi.id"/>
			<xsl:variable name="nombre" select="Foundation.Core.ModelElement.name"/>			
			
			<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Variable']">

				<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
				
					<variable>
						<xsl:attribute name="name">														
							<xsl:if test="not(contains(../Foundation.Extension_Mechanisms.TaggedValue.value,'='))">
								<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')"/>
							</xsl:if>
							<xsl:if test="contains(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')">
								<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/>
							</xsl:if>
						</xsl:attribute>
						<xsl:attribute name="informationType">
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='Clock'">
								<xsl:text>tns:</xsl:text>
								<xsl:value-of select="'Clock'"/>
							</xsl:if>
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='Integer'">
								<xsl:text>xsd:</xsl:text>
								<xsl:value-of select="'int'"/>
							</xsl:if>
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='Boolean'">
								<xsl:text>xsd:</xsl:text>
								<xsl:value-of select="'boolean'"/>
							</xsl:if>
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='String'">
								<xsl:text>xsd:</xsl:text>
								<xsl:value-of select="'string'"/>
							</xsl:if>
							<xsl:if test="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,' ')='Exception'">
								<xsl:text>tns:</xsl:text>
								<xsl:value-of select="'exception'"/>
							</xsl:if>
						</xsl:attribute>
						<xsl:attribute name="roleTypes">
							<xsl:value-of select="$nombre"/>
						</xsl:attribute>
					</variable>
				</xsl:if>
				
			</xsl:for-each>
						
		</xsl:for-each>
		
	</xsl:template>
	
	<!--Plantilla creada para la definicion de los assign iniciales-->
	<xsl:template name="assign">
		
		<!--Asignar los valores a las variables que se hayan inicializado de los Actor-->
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor">
		
			<xsl:variable name="identificador" select="@xmi.id"/>
			<xsl:variable name="nombre" select="Foundation.Core.ModelElement.name"/>
			
			<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Variable']">

				<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
				
					<!--Se tiene que mirar que tenga un igual en el contenido-->
					<xsl:if test="contains(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')">
					
					<assign>
					   
					   <xsl:attribute name="roleType">						   
						     <xsl:value-of select="$nombre"/>						   
						</xsl:attribute>
					    	
					   <copy>  
					   
					   	  <xsl:attribute name="name">						   
						  	<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/>
						  	<xsl:text>_assign</xsl:text>						   
						  </xsl:attribute>
					      <source>
					      
						      <xsl:attribute name="expression">
							  	<xsl:value-of select="substring-after(substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,' '),'=')"/>							  	
							  </xsl:attribute>
					      
					      </source>
					      <target>
					      
					      	  <xsl:attribute name="variable">
							  	<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/>							  	
							  </xsl:attribute>
					      
					      </target>
					   </copy>
					</assign>
					
					</xsl:if>
					
				</xsl:if>
				
			</xsl:for-each>
						
		</xsl:for-each>
		
		<!--Asignar los valores a las variables que se hayan inicializado de los Lifeline-->
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole">
		
			<xsl:variable name="identificador" select="@xmi.id"/>
			<xsl:variable name="nombre" select="Foundation.Core.ModelElement.name"/>			
			
			<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Variable']">

				<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
				
					<!--Se tiene que mirar que tenga un igual en el contenido-->
					<xsl:if test="contains(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')">
					
					<assign>
					   
					   <xsl:attribute name="roleType">						   
						     <xsl:value-of select="$nombre"/>						   
						</xsl:attribute>
					    	
					   <copy>  
					   
					   	  <xsl:attribute name="name">						   
						  	<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/>
						  	<xsl:text>_assign</xsl:text>						   
						  </xsl:attribute>
					      <source>
					      
						      <xsl:attribute name="expression">
							  	<xsl:value-of select="substring-after(substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,' '),'=')"/>							  	
							  </xsl:attribute>
					      
					      </source>
					      <target>
					      
					      	  <xsl:attribute name="variable">
							  	<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/>							  	
							  </xsl:attribute>
					      
					      </target>
					   </copy>
					</assign>
					
					</xsl:if>
					
				</xsl:if>
				
			</xsl:for-each>
						
		</xsl:for-each>
		
	</xsl:template>
	
	<!--Plantilla creada para la definicion de las interacciones-->
	<xsl:template name="interaction">
		
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.Collaborations/Behavioral_Elements.Collaborations.Collaboration.interaction/Behavioral_Elements.Collaborations.Message">
			
			<xsl:variable name="nombre" select="translate(Foundation.Core.ModelElement.name,' .:','___')"/>
			<xsl:variable name="identificador" select="@xmi.id"/>
			
			<xsl:value-of select="$identificador"/>			
			<interaction>
			
				<xsl:attribute name="parent">
					<xsl:value-of select="Behavioral_Elements.Collaborations.Message.frame/Foundation.Extension_Mechanisms.Stereotype/@xmi.idref"/>
				</xsl:attribute>				
				
				<xsl:attribute name="name">
				   <xsl:if test="contains(Foundation.Core.ModelElement.name,'_')">
					<xsl:value-of select="translate(substring-after(Foundation.Core.ModelElement.name,'_'),' .:','___')"/>
                   </xsl:if>
				   <xsl:if test="not(contains(Foundation.Core.ModelElement.name,'_'))">
				     <xsl:value-of select="translate(Foundation.Core.ModelElement.name,' .:','___')"/>
				   </xsl:if>
				</xsl:attribute>
				<xsl:attribute name="operation">
				    <xsl:if test="contains(Foundation.Core.ModelElement.name,'_')">
					<xsl:value-of select="translate(substring-after(Foundation.Core.ModelElement.name,'_'),' .:','___')"/>
                   </xsl:if>
				   <xsl:if test="not(contains(Foundation.Core.ModelElement.name,'_'))">
				     <xsl:value-of select="translate(Foundation.Core.ModelElement.name,' .:','___')"/>
				   </xsl:if>
				
				</xsl:attribute>
				<xsl:attribute name="channelVariable">canal</xsl:attribute>
				
				<!--Si está dentro de un frame de tipo par se deja marcado en que parte está-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='parOrder']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="parseq">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>
				
				<!--Si está dentro de un frame de tipo alt se deja marcado en que parte está-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='altOrder']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="altseq">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>
					
				</xsl:for-each>
				
				<!--Si está dentro de un frame de tipo alt_else se deja marcado en cual de las dos partes está-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='altelseOrder']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="altelseseq">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>
					
				</xsl:for-each>
				
				<orden>													
					<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='sequenceNumber']">

						<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">							
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:if>
						
					</xsl:for-each>
				</orden>
				
				<!--Variables con los identificadores del origen y del destino-->
				<xsl:variable name="id_sour" select="Behavioral_Elements.Collaborations.Message.sender/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>
			
				<xsl:variable name="id_dest" select="Behavioral_Elements.Collaborations.Message.receiver/Behavioral_Elements.Collaborations.ClassifierRole/@xmi.idref"/>

				<participate>
					<xsl:attribute name="relationshipType">
						
						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]">
					
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
							
						</xsl:if>
						
						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]">
						
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
							
						</xsl:if>
					
						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
						</xsl:if>
						
						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
						
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
							
						</xsl:if>						
						
					</xsl:attribute>

					<xsl:attribute name="fromRole">

						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]">
					
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
							
						</xsl:if>
						
						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]">
						
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_sour]/Foundation.Core.ModelElement.name,' .:','___')"/>
							
						</xsl:if>
						
						<xsl:text>RoleType</xsl:text>
						
					</xsl:attribute>

					<xsl:attribute name="toRole">
					
						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]">
					
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Use_Cases.Actor[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
						
						</xsl:if>
						
						<xsl:if test="/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]">
						
							<xsl:value-of select="translate(/XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Behavioral_Elements.Collaborations.ClassifierRole[@xmi.id = $id_dest]/Foundation.Core.ModelElement.name,' .:','___')"/>
							
						</xsl:if>							
						
						<xsl:text>RoleType</xsl:text>
						
					</xsl:attribute>
					
					
				</participate>

				<!--Request exchange-->
				<exchange>
				
					<xsl:attribute name="name">
						<xsl:if test="contains(Foundation.Core.ModelElement.name,'_')">
							<xsl:value-of select="translate(substring-after(Foundation.Core.ModelElement.name,'_'),' .:','___')"/><xsl:text>Exchange</xsl:text>
						</xsl:if>
						<xsl:if test="not(contains(Foundation.Core.ModelElement.name,'_'))">
							<xsl:value-of select="translate(Foundation.Core.ModelElement.name,' .:','___')"/><xsl:text>Exchange</xsl:text>
						</xsl:if>
					</xsl:attribute>
					<xsl:attribute name="action">					
						<!--En este caso los mensajes siempre serán de tipo request-->
						<xsl:text>request</xsl:text>											
					</xsl:attribute>
					
					<!--Añadir send si se intercambia alguna variable-->
					<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='send_variable']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
					
						<send>
						
							<xsl:attribute name="variable">
							
								<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
							
							</xsl:attribute>							
						
						</send>
						
					</xsl:if>
					
					</xsl:for-each>
					
					<!--Añadir receive si se intercambia alguna variable-->
					<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='receive_variable']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
					
						<receive>
						
							<xsl:attribute name="variable">
							
								<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
							
							</xsl:attribute>							
						
						</receive>
						
					</xsl:if>
					
					</xsl:for-each>
					
				</exchange>
				
				<!--Respond exchange-->
				<exchange>
				
					<xsl:attribute name="name">
						<xsl:if test="contains(Foundation.Core.ModelElement.name,'_')">
							<xsl:value-of select="translate(substring-after(Foundation.Core.ModelElement.name,'_'),' .:','___')"/><xsl:text>ExchangeACK</xsl:text>
						</xsl:if>
						<xsl:if test="not(contains(Foundation.Core.ModelElement.name,'_'))">
							<xsl:value-of select="translate(Foundation.Core.ModelElement.name,' .:','___')"/><xsl:text>ExchangeACK</xsl:text>
						</xsl:if>
					</xsl:attribute>
					<xsl:attribute name="action">					
						<!--En este caso los mensajes siempre serán de tipo respond-->
						<xsl:text>respond</xsl:text>											
					</xsl:attribute>
					
					<!--Añadir send y receive intercambiando la variable ACK-->
					<send>
						
						<xsl:attribute name="variable">
						
							<xsl:value-of select="'ACKVariable'"/>
						
						</xsl:attribute>							
					
					</send>
						
					<receive>
						
						<xsl:attribute name="variable">
						
							<xsl:value-of select="'ACKVariable'"/>
						
						</xsl:attribute>							
					
					</receive>
					
				</exchange>
				
				<!--Añadir otro exchange respond si la interacción genera una excepción nombrada-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='exception']">
			
				<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
				
					<exchange>
				
					<xsl:attribute name="name">
						<xsl:if test="contains(Foundation.Core.ModelElement.name,'_')">
							<xsl:value-of select="translate(substring-after(Foundation.Core.ModelElement.name,'_'),' .:','___')"/><xsl:text>ExchangeException</xsl:text><xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:if>
						<xsl:if test="not(contains(Foundation.Core.ModelElement.name,'_'))">
							<xsl:value-of select="translate(Foundation.Core.ModelElement.name,' .:','___')"/><xsl:text>ExchangeException</xsl:text><xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:if>
					</xsl:attribute>
					<xsl:attribute name="faultName">
						<xsl:if test="contains(Foundation.Core.ModelElement.name,'_')">
							<xsl:value-of select="translate(substring-after(Foundation.Core.ModelElement.name,'_'),' .:','___')"/><xsl:text>ExchangeException</xsl:text><xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:if>
						<xsl:if test="not(contains(Foundation.Core.ModelElement.name,'_'))">
							<xsl:value-of select="translate(Foundation.Core.ModelElement.name,' .:','___')"/><xsl:text>ExchangeException</xsl:text><xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:if>
					</xsl:attribute>
					<xsl:attribute name="action">					
						<!--En este caso los mensajes siempre serán de tipo respond-->
						<xsl:text>respond</xsl:text>											
					</xsl:attribute>
					
					<!--Añadir send de la variable de excepción-->
					<send>
					
						<xsl:attribute name="variable">
						
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						
						</xsl:attribute>							
						
						<xsl:attribute name="causeException">
						
							<xsl:text>tns:</xsl:text><xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						
						</xsl:attribute>
					
					</send>
					
					<!--Añadir receive de la variable de excepción-->
					<receive>
					
						<xsl:attribute name="variable">
						
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						
						</xsl:attribute>
						
						<xsl:attribute name="causeException">
						
							<xsl:text>tns:</xsl:text><xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						
						</xsl:attribute>							
					
					</receive>
					
				</exchange>
					
				</xsl:if>
				
				</xsl:for-each>
				
				<!--records para la actualización de las variables que haya en el mensaje-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='update']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
					
						<record>
						
							<xsl:attribute name="name">
							
								<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/><xsl:text>_update</xsl:text>
							
							</xsl:attribute>
							
							<xsl:attribute name="when">
							
								<xsl:value-of select="'after'"/>
							
							</xsl:attribute>
							
							<source>
							
								<xsl:attribute name="variable">
							
									<xsl:value-of select="substring-after(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/>
								
								</xsl:attribute>
							
							</source>
							
							<target>
							
								<xsl:attribute name="variable">
							
									<xsl:value-of select="substring-before(../Foundation.Extension_Mechanisms.TaggedValue.value,'=')"/>
								
								</xsl:attribute>
							
							</target>
						
						</record>
						
					</xsl:if>
					
				</xsl:for-each>
				
				<!--Añadir timeouts si existen-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='timeout']">
					
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">								
					
					<timeout>
							
						<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
										
					</timeout>
					
					</xsl:if>
				
				</xsl:for-each>
								
			</interaction>
			
		</xsl:for-each>
		
		<!--Añadir también los frames empleados en el diagrama-->
		
		<xsl:for-each select="XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.Stereotype">
		
			<xsl:variable name="nombre" select="Foundation.Core.ModelElement.name"/>			

			<xsl:variable name="identificador" select="@xmi.id"/>
			<xsl:value-of select="$identificador"/>
			
			<frames>
			
				<xsl:attribute name="name">				   
					<xsl:value-of select="$nombre"/>                   
				</xsl:attribute>
				
				<xsl:attribute name="idframe">				   
					<xsl:value-of select="$identificador"/>                   
				</xsl:attribute>
				
				<xsl:attribute name="parent">
					<xsl:value-of select="Foundation.Extension_Mechanisms.Stereotype.frame/Foundation.Extension_Mechanisms.Stereotype/@xmi.idref"/>
				</xsl:attribute>
				
				<!--Si está dentro de un frame de tipo par se deja marcado en que parte está-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='parOrder']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="parseq">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>
					
				</xsl:for-each>
				
				<!--Si está dentro de un frame de tipo alt se deja marcado en que parte está-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='altOrder']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="altseq">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>
				
				<!--Si está dentro de un frame de tipo alt_else se deja marcado en que parte está-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='altelseOrder']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="altelseseq">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>
				
				<!--Dejar marcada la guarda si tiene el frame-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Guard']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="guard">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>
				
				<!--Dejar marcado el repeat si tiene el frame-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Repeat']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="repeat">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>
				
				<!--Dejar marcada la guarda invertida si tiene el frame-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Guard_invert']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="guard_invert">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>
				
				<!--Dejar marcado el repeat invertido si tiene el frame-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Repeat_invert']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="repeat_invert">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>
				
				<!--Dejar marcada la excepción tratada si tiene el frame-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Exception']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="exception">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>
				
				<!--Dejar indicado el número de elementos que contiene el frame-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='elements']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="elements">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>	
				
				<!--Dejar indicado si el frame es bloqueante-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='block']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="block">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>				
								
				
				<!--Orden del frame en el diagrama-->				
				<orden>
					<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='sequenceNumber']">									

						<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">							
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:if>
						
					</xsl:for-each>
				</orden>
								
			</frames>
			
			<!--Añadir marcas que indiquen el final de un frame en el orden correspondiente-->
			<frames_end>
			
				<xsl:attribute name="name">				   
					<xsl:value-of select="$nombre"/>                   
				</xsl:attribute>
				
				<xsl:attribute name="idframe">				   
					<xsl:value-of select="$identificador"/>                   
				</xsl:attribute>
				
				<!--Dejar marcada la guarda del frame-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='Guard']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						<xsl:attribute name="guard">
							<xsl:value-of select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>
						</xsl:attribute>
					</xsl:if>					
					
				</xsl:for-each>				
								
				<!--Dejar indicado el número de elementos que contiene el frame-->
				<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='elements']">
				
					<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">
						
							<xsl:variable name="elementos" select="../Foundation.Extension_Mechanisms.TaggedValue.value"/>							
							
							<!--Orden del final del frame en el diagrama-->
							<orden>
								<xsl:for-each select="//XMI/XMI.content/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.TaggedValue/Foundation.Extension_Mechanisms.TaggedValue.tag[.='sequenceNumber']">									
			
									<xsl:if test="../Foundation.Extension_Mechanisms.TaggedValue.modelElement/Foundation.Core.ModelElement[@xmi.idref=$identificador]">							
										<xsl:value-of select="(../Foundation.Extension_Mechanisms.TaggedValue.value) + $elementos + 1"/>
									</xsl:if>
									
								</xsl:for-each>
							</orden>
						
					</xsl:if>					
					
				</xsl:for-each>	
				
				
												
			</frames_end>
												
		</xsl:for-each>
		
	</xsl:template>

</xsl:stylesheet>