Wednesday, April 8, 2009

Favorite_Music_XSL

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<head>
<title>
Favorite Music
</title>
</head>
<body>
<xsl:apply-templates select="FAVORITE_MUSIC"/>
</body>
</html>
</xsl:template>

<xsl:template match="FAVORITE_MUSIC">
<h1>Favorite Music</h1>
<table border="1">
<th bgcolor="#9acd32">Albums</th>
<th bgcolor="#9acd32">Artits</th>
<th bgcolor="#9acd32">Track 1</th>
<th bgcolor="#9acd32">Track 2</th>
<th bgcolor="#9acd32">Track 3</th>
<th bgcolor="#9acd32">Track 4</th>
<th bgcolor="#9acd32">Track 5</th>
<xsl:apply-templates select="CD">
<xsl:sort select="ALBUM"/>
</xsl:apply-templates>
</table>
</xsl:template>

<xsl:template match="CD">

<tr>
<td><xsl:apply-templates select="ALBUM"/></td>
<td><xsl:apply-templates select="ARTIST"/></td>

<xsl:for-each select="TRACKS">
<td><xsl:apply-templates select="TRACK1"/></td>
<td><xsl:apply-templates select="TRACK2"/></td>
<td><xsl:apply-templates select="TRACK3"/></td>
<td><xsl:apply-templates select="TRACK4"/></td>
<td><xsl:apply-templates select="TRACK5"/></td>
</xsl:for-each>
</tr>

</xsl:template>

</xsl:stylesheet>