Subject: [xsl] Parsing my itunes library with xsl! From: Søren Jepsen <sje@xxxxxxxxxxx> Date: Tue, 6 Mar 2007 17:37:32 +0100 |
I'm currently trying to parse my ITunes library.xml file into a more =20 neatly xml structure (example):
<Library> <Genre genre=3D"Miscellaneous"> <Artist Name=3D"Aretha Franklin"> <Album Title=3D"Queen of Soul: The Atlantic Recordings (2 of 4)"> <Tracks/> </Album> </Artist> <Artist Name=3D"Aretha Franklin"> <Album Title=3D"Queen of Soul: The Atlantic Recordings (3 of 4)"> <Tracks/> </Album> </Artist> <Artist Name=3D"Max Graham vs Yes"> <Album Title=3D"Absolute Summer Hits 2005"> <Tracks/> </Album> </Artist> </Genre> </Library>
My problem is i want the following structure, where the Artist is =20 only listed once, and contains multiple albums below the artist:
<Library> <Genre genre=3D"Miscellaneous"> <Artist Name=3D"Aretha Franklin"> <Album Title=3D"Queen of Soul: The Atlantic Recordings (2 of 4)"> <Tracks/> </Album> <Album Title=3D"Queen of Soul: The Atlantic Recordings (3 of 4)"> <Tracks/> </Album> </Artist> <Artist Name=3D"Max Graham vs Yes"> <Album Title=3D"Absolute Summer Hits 2005"> <Tracks/> </Album> </Artist> </Genre> </Library>
=3D'Genre']"/> </xsl:call-template> </xsl:for-each> </xsl:for-each> </Library> </xsl:template>
<xsl:template name=3D"albumsInGenre"> <xsl:param name=3D"genre"/> <xsl:variable name=3D"song" select=3D"/plist/dict/dict/dict"/>
<Genre> <xsl:attribute name=3D"genre"> <xsl:value-of select=3D"$genre"/> </xsl:attribute>
<xsl:for-each select=3D"$song[generate-id(.)=3Dgenerate-id(key=20 ('songsByAlbum',string[preceding-sibling::key[1]=3D'Album'])[1])]">
<Artist> <xsl:call-template name=3D"artistName"/> <Album> <xsl:call-template name=3D"albumName"/> </Album> </Artist>
</xsl:for-each> </xsl:for-each> </Genre> </xsl:template>
<xsl:template name=3D"albumName"> <xsl:attribute name=3D"Title"> <xsl:value-of select=3D"string[preceding-sibling::key[1]=3D'Album']"/> </xsl:attribute> </xsl:template>
<xsl:template name=3D"artistName"> <xsl:attribute name=3D"Name"> <xsl:value-of select=3D"string[preceding-sibling::key[1]=3D'Artist']"/> </xsl:attribute> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Fwd: Removing blank lines, David Carlisle | Thread | [xsl] Ideas/Panelist for XSLT Panel, Lindsey Simon |
Re: [xsl] Fwd: Removing blank lines, David Carlisle | Date | [xsl] Ideas/Panelist for XSLT Panel, Lindsey Simon |
Month |