[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Figuring out for-group-by

Subject: Re: Figuring out for-group-by
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 9 Jul 2004 22:10:51 +0100
apple lossless
Hi Barry,

> In case you are wondering, I am trying to fix my iTunes library
> which has duplicate entries in it as a result of converting
> everything to Apple Lossless encoding. Looking at the results I can
> see that the attribute labelled 'key' gives me all of the track Ids
> matching the compound key. The fact that there are more than one is
> the issue. What I would like to do is identify the track Id(s)
> associated with the entry that has
>
> <key>Kind</key><string>Apple Lossless audio file</string>
>
> within it.

Are you saying that the only <dict> elements that you want to keep are
those with <key>Kind</key><string>Apple Lossless audio file</string>?

If so, you can select just those <dict> elements with:

  /plist/dict/dict/dict
    [key[. = 'Kind']/following-sibling::string[1] =
     'Apple Lossless audio file']

If selecting just these gives you unique tracks, then you only need to
do a <xsl:for-each> -- no need for any additional grouping. Otherwise,
you can use the above expression in the select attribute of the
<xsl:for-each-group> that you're currently using.
  
I'm not sure what you mean by "the attribute labelled 'key' gives me
all of the track Ids matching the compound key" but if you can
identify the unique tracks by their track ids, then there's no need to
use the compound key.

Later, you wrote:
> I am getting a little closer. I have managed to pull out
> more-or-less what I am after with
> 
> <xsl:value-of select="current-group()/key[string() = 
> 'Kind']/following-sibling::string[1][string() = 'Apple Lossless audio 
> file']/preceding-sibling::key[string() = 'Track 
> ID']/following-sibling::integer[1]"/>
> 
> but I am concerned that the various keys may not always be in this
> order so the "preceding-sibling" search may not work. I can see that
> I can use for-each with current-group to iterate through the sets of
> keys so that may be more efficient than chasing up and down the
> tree.

This gives you the track ID as long as the Kind of the track is 'Apple
Lossless audio file'. A clearer way of doing this would be to use:

  <xsl:if test="current-group()
                  /key[. = 'Kind']
                    /following-sibling::string[1] =
                'Apple Lossless audio file'">
    <xsl:value-of select="current-group()
                            /key[. = 'Track ID']
                              /following-sibling::integer[1]" />
  </xsl:if>

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.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.