<?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 list stylesheet 4.0
     written: 	6/3/00
     modified:  12/10/00
     author: 	xyster

     comments: 	
-->
     
<xsl:template match="list">
	<html>
		<xsl:comment> Transformed from XML with Lister XSL list stylesheet 4.0. Written by xyster </xsl:comment>
		<xsl:comment> Basepath='<xsl:value-of select="basepath" />' </xsl:comment>
		<head>
	    	<title>Media List</title>      
	    </head>
    	<body>
	        <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">
	<p>
	<table width="100%" border="1">
	<tr>
		<td>Title</td>
		<td>Duration</td>
		<td>Channels</td>
		<td>Frequency</td>
		<td>Bitrate</td>
        <td>Type</td>
		<td>Dimensions</td>
        <td>Comment</td>
	</tr>
	<!-- artist -->
	<xsl:for-each select="object">
        <xsl:sort select="attrib/name" />
       	<!-- albums -->
       	<xsl:for-each select="children/object">
            <xsl:sort select="attrib/name" />
            <!-- songs -->
            <xsl:for-each select="children/object">
               	<xsl:sort select="attrib/name" />
               	<tr>
               		<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>N/A</xsl:otherwise>
					</xsl:choose>
               		</td>
                    <td>
                   	<xsl:choose>
                   	   	<xsl:when test="attrib/comment != ''">
                    		<xsl:value-of select="attrib/comment" />
						</xsl:when>	
						<xsl:otherwise>None</xsl:otherwise>
					</xsl:choose>
                    </td>
               	</tr>
            </xsl:for-each>
       	    <!-- /songs -->
       	</xsl:for-each>
	    <!-- /albums -->
	</xsl:for-each>
	<!-- /artist -->
	
	</table>
	</p>
</xsl:template>

<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="readerstats/object/children">
	<p>
	<table border="1" cellpadding="1" cellspacing="0">
	<tr>
		<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>
        	<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>
