Skip to content

Instantly share code, notes, and snippets.

@tillig
Created January 4, 2017 23:36
Show Gist options
  • Save tillig/a9f1aeb445bc5e63b8050da15a98096c to your computer and use it in GitHub Desktop.
Save tillig/a9f1aeb445bc5e63b8050da15a98096c to your computer and use it in GitHub Desktop.
XSL to convert your iTunes library to an HTML table
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<table border="1">
<tr>
<th>Track ID</th>
<th>Name</th>
<th>Artist</th>
<th>Album</th>
<th>Genre</th>
<th>Kind</th>
<th>Size</th>
<th>Total Time</th>
<th>Disc Number</th>
<th>Disc Count</th>
<th>Track Number</th>
<th>Track Count</th>
<th>Year</th>
<th>Date Modified</th>
<th>Date Added</th>
<th>Bit Rate</th>
<th>Sample Rate</th>
<th>Play Count</th>
<th>Play Date</th>
<th>Normalization</th>
<th>File Type</th>
<th>File Creator</th>
<th>Location</th>
<th>File Folder Count</th>
<th>Library Folder Count</th>
</tr>
<xsl:call-template name="records" />
</table>
</xsl:template>
<xsl:template name="records">
<xsl:for-each select="/*/*/dict[1]/dict">
<xsl:element name="tr">
<xsl:call-template name="songs" />
</xsl:element>
</xsl:for-each>
</xsl:template>
<xsl:template name="songs">
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Track ID']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Name']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Artist']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Album']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Genre']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Kind']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Size']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Total Time']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Disc Number']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Disc Count']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Track Number']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Track Count']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Year']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Date Modified']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Date Added']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Bit Rate']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Sample Rate']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Play Count']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Play Date']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Normalization']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'File Type']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'File Creator']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Location']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'File Folder Count']" />
</td>
<td>
<xsl:value-of select="child::*[preceding-sibling::* = 'Library Folder Count']" />
</td>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment