<?xml version="1.0"?>

<!--
	Author: Mael Guillemot
	File: icsi-to-html.xsl
	Date: April 2004
	Purpose: Transform ICSI XML transcription into HTML
--> 

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:exsl="http://exslt.org/common"
		extension-element-prefixes="exsl">


<xsl:output method="html" indent="yes" encoding="ISO-8859-1"/>
<xsl:strip-space elements="*"/>


<xsl:variable name="TheParticipants">
 <xsl:for-each select="/Meeting/Preamble/Participants">
 <xsl:for-each select="Participant">
        <xsl:element name="Aparticipant">
                <xsl:attribute name="num"><xsl:value-of select="@Name"/></xsl:attribute>
                <xsl:attribute name="id"><xsl:value-of select="position()"/></xsl:attribute>
		akualleele
        </xsl:element>
 </xsl:for-each>
 </xsl:for-each>
</xsl:variable>


<xsl:variable name="colour">

  <xsl:element name="Color"><xsl:attribute name="ID">1</xsl:attribute><xsl:attribute name="val">black</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">2</xsl:attribute><xsl:attribute name="val">blue</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">3</xsl:attribute><xsl:attribute name="val">green</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">4</xsl:attribute><xsl:attribute name="val">red</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">5</xsl:attribute><xsl:attribute name="val">purple</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">6</xsl:attribute><xsl:attribute name="val">maroon</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">7</xsl:attribute><xsl:attribute name="val">orange</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">8</xsl:attribute><xsl:attribute name="val">olive</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">9</xsl:attribute><xsl:attribute name="val">fuchsia</xsl:attribute></xsl:element>	
  <xsl:element name="Color"><xsl:attribute name="ID">10</xsl:attribute><xsl:attribute name="val">teal</xsl:attribute></xsl:element>

</xsl:variable>	



<xsl:template match="/">


<html>
	<body>
	<table>
		<xsl:apply-templates select="/Meeting">
		</xsl:apply-templates>
	</table>
	<hr></hr>
	<table>
		<xsl:apply-templates select="/Meeting/Preamble">
		</xsl:apply-templates>
	</table>
	<hr></hr>
	<h1>Transcript</h1>
		<xsl:apply-templates select="/Meeting/Transcript">
		</xsl:apply-templates>
	</body>
</html>
</xsl:template>



<xsl:template match="Meeting">
	<h1>ICSI Meeting: <xsl:value-of select="@Session"/></h1>
<xsl:text> DateTimeStamp: </xsl:text>
<xsl:value-of select="@DateTimeStamp"/>
<xsl:text> | VersionDate: </xsl:text>
<xsl:value-of select="@VersionDate"/>
<xsl:text>&#xA;</xsl:text>
</xsl:template>




<xsl:template match="Preamble">
		<xsl:apply-templates select="Notes">
		</xsl:apply-templates>
		<xsl:apply-templates select="Participants">
		</xsl:apply-templates>
</xsl:template>




<xsl:template match="Transcript">
<h2>StartTime: <xsl:value-of select="@StartTime"/> | EndTime:  <xsl:value-of select="@EndTime"/></h2>
	<table>
		<xsl:apply-templates select="Segment">
		</xsl:apply-templates>
	</table>
</xsl:template>



<xsl:template match="Notes">
<h2>General notes about the meeting:</h2>
<br></br>
<xsl:value-of select="."/>
</xsl:template>




<xsl:template match="Participants">

<xsl:text>Participants:</xsl:text>
<xsl:text>&#xA;</xsl:text>
    <table border="1">
      <tr bgcolor="#9acd32">
        <th align="left">Participant ID</th>
        <th align="left">Channel</th>
      </tr>
      <xsl:for-each select="Participant">
      <tr>
        <td>
              <xsl:value-of select="@Name"/>
        </td>
        <td>
              <xsl:value-of select="@Channel"/>
        </td>


      </tr>
      </xsl:for-each>
	</table>
</xsl:template>



<xsl:template match="Segment">
<tr>
<td>


<b><xsl:value-of select="@Participant"/></b>
<font size="-1"><font color="gray">_[<xsl:value-of select="@StartTime"/>]: 
</font></font>
<b>
<xsl:element name="font">
<xsl:attribute name="color">


<xsl:call-template name="printColorOf">
 <xsl:with-param name="ParticipantName" select="@Participant"/>
</xsl:call-template>


</xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</b>
<font size="-1"><font color="gray">
[<xsl:value-of select="@EndTime"/>]
</font></font>
</td>
</tr>
<xsl:text>&#xA;</xsl:text>
</xsl:template>


<xsl:template name="printColorOf">
<xsl:param name="ParticipantName"></xsl:param>

<xsl:variable name="Nb">
<xsl:value-of select="exsl:node-set($TheParticipants)/Aparticipant[@num=$ParticipantName]/@id"/>
</xsl:variable>

<xsl:value-of select="exsl:node-set($colour)/Color[@ID=$Nb]/@val"/>
</xsl:template>
 


</xsl:stylesheet>

