Re: [xsl] Figuring out for-group-by

Subject: Re: [xsl] Figuring out for-group-by
From: Barry Lay <blay@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 09 Jul 2004 18:44:23 -0400

Thanks. I didn't explain what I was going to do next. There's more to the input XML - it also contains playlists which refer to the tracks in the master list by Id, and which were not updated by the original conversion process to point to the new versions of the tracks. If I just remove the old tracks the playlists will be orphaned. I need to create a list of old-Id-to-new-Id maps to fix the playlists, then I can get rid of the extras. I also want to create a shell script to blow away the old audio files as they are taking up a lot of disk space.

What I thought to do was to group the tracks by the natural key so that I would have the old Ids and new Ids in one spot. The XSL I included was mainly to get used to for-each-group which I have never used. I was initially surprised by the result of

<xsl:value-of select="current-group()/key[string() = 'Track ID']/following-sibling::integer[1]"/>

which gives me all of the Ids for the dict elements that match the key. This gives me the old Ids as well as the new Ids. I thought that once I pick a new Id based on the 'Kind' (any of the lossless ones will do since they are identical) I could just use for-each to create elements that map the old to new and use that in subsequent processing.


Jeni Tennison wrote:

But I suggest that you only select (and group) the <dict> elements
whose Kind is 'Apple Lossless audio file' rather than filtering the
others out after going to the effort of grouping them.


Jeni Tennison

Current Thread