<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

	<xsl:output method="html"/> 

    <!--
        root template
    -->
    
	<xsl:template match="/">
	
		<HTML>
        
        <STYLE TYPE="text/css">
            H2,H3 {
                display: inline;
            }
        </STYLE>
        
		<BODY STYLE="font-family: 'Comic Sans MS';line-height: 175%">
		
		<DIV>
			<H3>Log: </H3><xsl:value-of select="LOG/PATH"/>
		</DIV>
				        
        <xsl:apply-templates select="LOG/SOUND"/>
        
		<xsl:for-each select="LOG/EVENT">
        
			<xsl:sort select="CREATED"/>
			<xsl:sort select="CHANNEL"/>
            
			<xsl:apply-templates select="."/> 
            
		</xsl:for-each>
        		
		</BODY>
		</HTML>
		
	</xsl:template>

    <!--
        sound template
    -->
    
	<xsl:template match="SOUND">
    
		<DIV>
			<H3>Sound: </H3><xsl:value-of select="PATH"/>
		</DIV>
        
	</xsl:template>

    <!--
        event template
    -->
    
	<xsl:template match="EVENT">

    <DIV CLASS="EVENT" STYLE="
        border: 1px dotted rgb(128,128,128);
        background-color: rgb(255,255,200);
        margin: 2em 2em 2em 2em; 
        padding: 1em 1em 1em 1em;
    ">
    
		<DIV STYLE="
            border: 1px dotted rgb(128,128,128);
            padding: 8px;
            margin:0.5em;
            background-color: rgb(255,200,200);
        ">
			<H2>Event: #<xsl:apply-templates select="ID/MAT"/></H2>
		</DIV>
        
        <DIV>
			<H3>Channel: </H3><xsl:apply-templates select="CHANNEL/MAT"/>
		</DIV>
        
        <DIV>
			<H3>Time: </H3><xsl:apply-templates select="TIME/MAT"/>
		</DIV>
	  
		<DIV>
			<H3>Frequency: </H3><xsl:apply-templates select="FREQ/MAT"/>
		</DIV>
        
        <DIV>
			<H3>Author: </H3><xsl:value-of select="AUTHOR"/>
		</DIV>
		
        <DIV>
			<H3>Created: </H3><xsl:value-of select="CREATED"/>
		</DIV>
		
        <DIV>
			<H3>Modified: </H3><xsl:value-of select="MODIFIED"/>
		</DIV>
	  
		<xsl:apply-templates select="ANNOTATION"/>
        
		<xsl:apply-templates select="MEASUREMENT"/> 
        
    </DIV>
		
	</xsl:template>
  
    <!--
        annotation template
    -->
    
	<xsl:template match="ANNOTATION">
  
    <DIV CLASS="ANNOTATION" STYLE="
        border: 1px dotted rgb(100,200,100);
        background-color: rgb(200,255,200);
        margin: 1em 1em 1em 1em; 
        padding: 1em 1em 1em 1em;
    ">
    
        <DIV STYLE="
            border: 1px dotted rgb(128,128,128);
            padding: 8px;
            margin:0.5em;
        ">
			<H2>Annotation: <xsl:value-of select="NAME"/></H2>
		</DIV>

		<DIV>
            <H3>Value:</H3>
            <DIV STYLE="background-color: rgb(220,255,220);">
                <xsl:apply-templates select="VALUE/*/CHAR"/>
            </DIV>
		</DIV>
		
		<DIV>
			<H3>Author: </H3><xsl:value-of select="AUTHOR"/>
		</DIV>
		
		<DIV>
			<H3>Created: </H3><xsl:value-of select="CREATED"/>
		</DIV>
		
        <DIV>
			<H3>Modified: </H3><xsl:value-of select="MODIFIED"/>
		</DIV>
	 
    </DIV>
    
    </xsl:template>
	
    <!--
        measurement template
    -->
    
    <xsl:template match="MEASUREMENT">
  
    <DIV CLASS="MEASUREMENT" STYLE="
        border: 1px dotted rgb(100,100,200);
        background-color: rgb(200,200,255); 
        margin: 1em 1em 1em 1em; 
        padding: 1em 1em 1em 1em;
    ">
    
        <DIV STYLE="
            border: 1px dotted rgb(128,128,128);
            padding: 8px;
            margin:0.5em;
        ">
			<H2>Measurement: <xsl:value-of select="NAME/CHAR"/></H2>
		</DIV>

		<DIV>
			<H3>Value:</H3>
            <DIV STYLE="background-color: rgb(220,220,255);">
                <xsl:apply-templates select="VALUE/*/MAT"/>
            </DIV>
		</DIV>
        
        <DIV>
			<H3>Parameter:</H3>
            <DIV STYLE="background-color: rgb(220,220,255);">
                <xsl:apply-templates select="PARAMETER/*/MAT"/>
            </DIV>
		</DIV>
		
		<DIV>
			<H3>Author: </H3><xsl:value-of select="AUTHOR"/>
		</DIV>
		
		<DIV>
			<H3>Created: </H3><xsl:value-of select="CREATED"/>
		</DIV>
		
        <DIV>
			<H3>Modified: </H3><xsl:value-of select="MODIFIED"/>
		</DIV>
        
    </DIV>
        	 
    </xsl:template>
    
       <!--
        display matrix nodes
    -->
    
    <xsl:template match="MAT">
                
        <!--
            display depending on dimensions of matrix
        -->
        
        <xsl:choose>
        
            <!-- 
                display scalars
            -->
            
            <xsl:when test="@dims = '0'">

                <SPAN>
                   <xsl:value-of select="."/>
                </SPAN>
 
            </xsl:when> 
            
            <!-- 
                display vectors 
            -->
            
            <xsl:when test="@dims = '1'">
                            
                <TABLE STYLE="
                    border: 1px dotted black;
                    margin: 8px;
                    vertical-align: middle; 
                    display: inline;
                ">
                
                <xsl:for-each select="E">
                    <TR STYLE="border: 1px dotted black;"><TD><xsl:value-of select="."/></TD></TR>
                </xsl:for-each>
                
                </TABLE>
                            
            </xsl:when>
            
            <!-- 
                display matrices 
            -->
            
            <xsl:when test="@dims = '2'">
                             
                <TABLE BORDER="2">
                
                <xsl:for-each select="R">
                    <TR>
                    <xsl:for-each select="E">
                        <TD><xsl:value-of select="."/></TD>
                    </xsl:for-each>
                    </TR>
                </xsl:for-each>
                
                </TABLE>
                            
            </xsl:when>
            
        </xsl:choose>
            
    </xsl:template>
    
    
    <xsl:template match="VALUE/*/CHAR|PARAMETER/*/CHAR">
                    
        <TABLE STYLE="
            border: 1px dotted black;
            margin: 8px;
            vertical-align: bottom; 
        ">
                
        <H3>
            <TR STYLE="border: 1px dotted black;">
                <TD><xsl:value-of select="local-name(..)"/>: </TD>
                <TD STYLE="font-family: monospace;"><xsl:value-of select="."/></TD>
            </TR>
        </H3>
                
        </TABLE>
        
    </xsl:template>
    
    
    <xsl:template match="VALUE/*/MAT|PARAMETER/*/MAT">
                
        <!--
            display depending on dimensions of matrix
        -->
        
        <xsl:choose>
        
            <!-- 
                display scalars
            -->
            
            <xsl:when test="@dims = '0'">
            
                <TABLE STYLE="
                    border: 1px dotted black;
                    margin: 8px;
                    vertical-align: bottom; 
                ">
                
                <H3>
                    <TR STYLE="border: 1px dotted black;">
                        <TD><xsl:value-of select="local-name(..)"/>: </TD>
                        <TD STYLE="font-family: monospace;"><xsl:value-of select="."/></TD>
                    </TR>
                </H3>
                
                </TABLE>
                
            </xsl:when> 
            
            <!-- 
                display vectors 
            -->
            
            <xsl:when test="@dims = '1'">
                            
                <TABLE STYLE="
                    border: 1px dotted black;
                    margin: 8px;
                    vertical-align: bottom; 
                    display: inline;
                ">
                
                <xsl:for-each select="E">
                    <TR STYLE="border: 1px dotted black;"><TD><xsl:value-of select="."/></TD></TR>
                </xsl:for-each>
                
                </TABLE>
                            
            </xsl:when>
            
            <!-- 
                display matrices 
            -->
            
            <xsl:when test="@dims = '2'">
                             
                <TABLE BORDER="2">
                
                <xsl:for-each select="R">
                    <TR>
                    <xsl:for-each select="E">
                        <TD><xsl:value-of select="."/></TD>
                    </xsl:for-each>
                    </TR>
                </xsl:for-each>
                
                </TABLE>
                            
            </xsl:when>
            
        </xsl:choose>
            
    </xsl:template>
    
</xsl:stylesheet> 
