<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
<xsl:output method="html" indent="yes" />

<!-- Lister XSL XML->HTML colorful table stylesheet 5.0
     written: 	6/3/00
     modified:  10/10/00
     author: 	xyster

     comments: 	xsl sucks
-->
     
<xsl:template match="list">
	<html>
		<xsl:comment> Transformed from XML with Lister XSL colorful table stylesheet 5.0. Written by xyster </xsl:comment>
		<xsl:comment> Basepath='<xsl:value-of select="basepath" />' </xsl:comment>
		<head>
	    	<title>Media List</title>      
	    </head>
    	<body bgcolor="#003333" text="#00B2EB" link="#00FF00">
	        <center><h1>Media List</h1></center>
        	Generated by <a href="http://www.xyster.net"><xsl:value-of select="generator" /></a><br />
        	<xsl:apply-templates /> 
    	</body>
	</html>
</xsl:template>

<!-- gag spurious output -->
<xsl:template match="generator">
</xsl:template>

<!-- gag spurious output -->
<xsl:template match="basepath">
</xsl:template>

<!-- gag spurious output -->
<xsl:template match="object/attrib">
</xsl:template>

<xsl:template match="music/object/children">
<table width="100%" border="0">
	<!-- artist -->
	<xsl:for-each select="object">
        <xsl:sort select="attrib/name" />
        <!-- empty row -->
        <tr>
          	<td height="15" colspan="8"><xsl:comment>a</xsl:comment></td>
        </tr>
        <tr>
        <td  colspan="8"><font size="+2"><xsl:value-of select="attrib/name" /></font></td>
       	</tr>
        <!-- empty row -->
        <tr>
          	<td height="3" colspan="8"><xsl:comment>a</xsl:comment></td>
        </tr>
       	<!-- albums -->
       	<xsl:for-each select="children/object">
            <xsl:sort select="attrib/name" />
	        <!-- empty row -->
    	    <tr>
        	  	<td height="2" colspan="8"><xsl:comment>a</xsl:comment></td>
	        </tr>
         	<!-- album name -->
            	<tr bgcolor="#005555">
            		<td align="center" colspan="8">
            			<xsl:value-of select="../../attrib/name" /> - 
            			<xsl:value-of select="attrib/name" />
            		</td>
            	</tr>
                <!-- empty row -->
                <tr>
                	<td height="1" colspan="8"><xsl:comment>a</xsl:comment></td>
                </tr>
            <!-- songs -->
            <xsl:for-each select="children/object">
               	<xsl:sort select="attrib/name" />
               	<tr bgcolor="#002222">
               		<td>
               			<!-- link to the song -->
               			<!-- there is a problem with the href. Some characters which can be found in a directory
               			     name are no good in URLs and cause broken links. For instance #
               			     how to solve this?
               			-->    
               			<a href="{attrib/path}/{attrib/name}"><xsl:value-of select="attrib/title" /></a>
               		</td>
               	    <td align="right"><xsl:value-of select="attrib/duration" /></td>
               	    <td><xsl:value-of select="attrib/channels" /></td>
               	    <td align="right"><xsl:value-of select="attrib/frequency" /></td>
                    <td align="right"><xsl:value-of select="attrib/bitrate" /></td>
                    <td>
                   	<xsl:choose>
                       	<xsl:when test="attrib/xsize != '0'">Video</xsl:when>
			        	<xsl:otherwise>Audio</xsl:otherwise>
					</xsl:choose>
                    </td>
               		<td>
                   	<xsl:choose>
                       	<xsl:when test="attrib/xsize != '0'">
                       		<xsl:value-of select="attrib/xsize" />x<xsl:value-of select="attrib/ysize" />
                       	</xsl:when>
			        	<xsl:otherwise><font color="#002222">N/A</font></xsl:otherwise>
					</xsl:choose>
               		</td>
                    <td>
                   	<xsl:choose>
                   	   	<xsl:when test="attrib/comment != ''">
                    		<xsl:value-of select="attrib/comment" />
						</xsl:when>	
						<xsl:otherwise><font color="#002222">None</font></xsl:otherwise>
					</xsl:choose>
                    </td>
               	</tr>
            </xsl:for-each>
       	    <!-- /songs -->
       	    
       	</xsl:for-each>
	    <!-- /albums -->
		<!-- </p> -->
	</xsl:for-each>
	<!-- /artist -->
</table>
</xsl:template>


<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="readerstats/object/children">
	<p>
	<table>
	<tr bgcolor="#002222">
		<td><font size="+1">Reader Name</font></td>
		<td><font size="+1">Files Read</font></td>
		<td><font size="+1">Total Playing Time</font></td>
	</tr>	
	<xsl:for-each select="object">
        <tr bgcolor="#002222">
        	<td>
        		<xsl:value-of select="attrib/name" /><br />
        	</td>	
        	<td align="right">	
        		<xsl:value-of select="attrib/reads" /><br />
        	</td>
        	<td align="right">	
        		<xsl:value-of select="attrib/duration" /><br />
            </td>
        </tr>
    </xsl:for-each>
    </table>
    </p>
</xsl:template>

<xsl:template match="time">
	<p>Listed in <xsl:value-of select="." /> seconds</p>		
</xsl:template>

</xsl:stylesheet>
