<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      exclude-result-prefixes="xs"
      version="2.0">
	<xsl:output method="html" version="4.0" encoding="UTF-8" indent="yes"/>
	<xsl:key name="tracks-by-key" match="track" use="concat(artist,' - ', album, ' - ', genre)"/>
	<xsl:template match="/">
		<html>
			<head>
				<title><xsl:value-of select="/playlist/@name"/></title>
			</head>
			<body>
				<h1>Playlist: <xsl:value-of select="/playlist/@name"/></h1>
				<ul id="ArtistAlbumGenre">
					<xsl:for-each select="/playlist/track[count(. | key('tracks-by-key', concat(artist,' - ', album, ' - ', genre))[1]) = 1]">
						<xsl:sort select="artist"/>
						<xsl:sort select="album"/>
						<xsl:sort select="genre"/>
						<li><xsl:value-of select="artist"/> - <xsl:value-of select="album"/> - <xsl:value-of select="genre"/></li>
					</xsl:for-each>
				</ul>
				<!-- Please keep the following. Thank you! -->
				<p>Playlist last updated <xsl:value-of select="/playlist/information/updated"/>. Output generated by <a href="http://jamesrskemp.com/apps/iTunesPlaylists2Xml/?xslt" onclick="window.open(this.href);return false;">iTunes Playlists to Xml</a>.</p>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>