<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                exclude-result-prefixes="rdf dc rss content admin"
                version="1.0">
  <xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes" />
  
  <xsl:template match="/Document">
    <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:dc="http://purl.org/dc/elements/1.1/" 
             xmlns:rss="http://purl.org/rss/1.0/"
             xmlns:content="http://purl.org/rss/1.0/modules/content/"
             xmlns:admin="http://webns.net/mvcb/">

      <channel rdf:about="http://www.decafbad.com/blog">
        <title>iTunes Music Store<xsl:for-each select="./Path/PathElement"> - <xsl:value-of select="./@displayName" /></xsl:for-each></title>
        <link>itms://ax.phobos.apple.com.edgesuite.net<xsl:value-of select="Path/PathElement[last()]" /></link>
        <description>RSS feed scraped from the iTunes Music Store</description>
        <language>en</language>
        <admin:generatorAgent rdf:resource="http://www.decafbad.com/twiki/bin/view/ItunesMusicStoreToRss" />
        <admin:errorReportsTo rdf:resource="mailto:deus_x@pobox.com"/>
        
        <items>
          <rdf:Seq>
            <xsl:for-each select="//ViewAlbum/B/../../../../..">
              <rdf:li rdf:resource="itms://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewAlbum?playlistId={.//ViewAlbum/B/../@id}" />
            </xsl:for-each>
          </rdf:Seq>
        </items>
        
      </channel>
      
      <xsl:for-each select="//ViewAlbum/B/../../../../..">
          
        <item rdf:about="itms://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewAlbum?playlistId={.//ViewAlbum/B/../@id}">
          <title><xsl:value-of select=".//ViewAlbum/B" /> by <xsl:value-of select=".//ViewArtist" /></title>
          <link>itms://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewAlbum?playlistId=<xsl:value-of select=".//ViewAlbum/B/../@id" /></link>
          <description><xsl:call-template name="escapedItemContent" /></description>
          <content:encoded><xsl:call-template name="escapedItemContent" /></content:encoded>
        </item>
      </xsl:for-each>
    </rdf:RDF>
  </xsl:template>
  
  <xsl:template name="escapedItemContent">
    &lt;a href="itms://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewAlbum?playlistId=<xsl:value-of select=".//ViewAlbum/B/../@id" />"&gt;&lt;img src="<xsl:value-of select=".//ViewAlbum/PictureView/@url" />" /&gt;&lt;/a&gt;&lt;br /&gt;
  Title: &lt;a href="itms://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewAlbum?playlistId=<xsl:value-of select=".//ViewAlbum/B/../@id" />"&gt;<xsl:value-of select=".//ViewAlbum/B" />&lt;/a&gt;&lt;br /&gt;
    Artist: &lt;a href="itms://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewArtist?artistId=<xsl:value-of select=".//ViewArtist/@id" />"&gt;<xsl:value-of select=".//ViewArtist" />&lt;/a&gt;&lt;br /&gt;
  Genre: &lt;a href="itms://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.woa/wa/com.apple.jingle.app.store.DirectAction/viewGenre?genreId=<xsl:value-of select=".//ViewGenre/@id" />"&gt;<xsl:value-of select=".//ViewGenre" />&lt;/a&gt;&lt;br /&gt;
  </xsl:template>
  
</xsl:stylesheet>
