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

[no subject]

silver dawn mp3
I do a double grouping, once per artist, then per album. Underneath all this
I list the various tracks. The particularity is that I list not only the
tracks the artist has participated on but the whole list of tracks for a
particular record. All this I've achieved already and looks like this:

- artist1
  - album1
    - track1
    - track2
  - album2
    - track1
    - track2
- artist2
  - album1
    - track1


Looking at the data supplied this gives us:

- Artemis
  - Earth Volume 2
    - Fictions
    - Silver Dawn
    - Artifical Life
- Odyssey
  - Earth Volume 2
    - Fictions
    - Silver Dawn
    - Artifical Life
- Pearl Jam
  - Ten
    - Why Go
    - Black
- Rollercone
  - Earth Volume 2
    - Fictions
    - Silver Dawn
    - Artifical Life

What I'm breaking my teeth on is the following: I would like to compare the
name of the artist at the track level to the name of the artist I'm
currently working with at the top level.

Given the following data:
- 1
  - 1.1
    - 1.1.1
    - 1.1.2
    - 1.1.3
I would like to compare the artist name of "1.1.3" with the artist name of
"1" and if they are the same then do some text formatting. The problem I
have is that I have not found a way to get the name of the artist at "1". I
had hoped it would be as simple as doing a simple test like the one below,
but alas, that was a little too optimistic.

  <xsl:if test="../../artist/displayname != artist/displayname">

Below is my XSL code as well as some XML source. I'd be grateful if you
could have a look at it.

- Thomas


-------[BEGIN SOURCE XSL]--------
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
     doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>

<xsl:key name="artists"
         match="mp3"
         use="artist/displayname" />
<xsl:key name="albums"
         match="mp3"
         use="album/displayname" />
<xsl:key name="artists_albums"
         match="mp3"
         use="concat(artist/displayname, ' ',
                     album/displayname)" />

<xsl:template match="mp3list">
  <html>
    <head>
    </head>
    <body>
      <xsl:for-each
           select="mp3[count(. | key('artists', artist/displayname)[1]) =
1]">
        <xsl:sort select="artist/displayname" />
        <xsl:variable name="top_artist" select="artist/displayname" />
        <h1><xsl:value-of select="$top_artist" /></h1>

        <xsl:variable
             name="album_items"
             select="key('artists', artist/displayname)" />
        <xsl:for-each select="$album_items[generate-id() =
generate-id(key('artists_albums', concat(artist/displayname, ' ',
album/displayname))[1])]">
          <xsl:sort select="album/displayname" />
          <xsl:call-template name="album_title"/>
          <xsl:call-template name="album_content"/>
        </xsl:for-each>
      </xsl:for-each>

      <xsl:call-template name="page_footer"/>

    </body>
  </html>
</xsl:template>

<xsl:template name="album_title">
    <xsl:element name="h3">
    <xsl:attribute name="id"><xsl:value-of
select="concat('h',generate-id(.))" /></xsl:attribute>
      <xsl:attribute name="class">header</xsl:attribute>
      <xsl:value-of select="album/displayname" />
    </xsl:element>
</xsl:template>

<xsl:template name="album_content">
    <xsl:element name="div">
      <xsl:attribute name="id"><xsl:value-of
select="concat('d',generate-id(.))" /></xsl:attribute>
      <xsl:attribute name="class">details</xsl:attribute>
      <table>
        <tr>
          <th>No.</th>
          <th>Title</th>
          <th>Length</th>
          <th>bitrate</th>
          <th>vbr</th>
        </tr>
        <xsl:for-each select="key('albums', album/displayname)">
          <xsl:sort select="trackindex" data-type="number"/>
        <tr>
          <xsl:call-template name="highlighter"/>
          <td><xsl:number format="01 " value="trackindex"/></td>
          <td><xsl:value-of select="title"/></td>
          <td><xsl:value-of select="length"/></td>
          <td><xsl:value-of select="bitrate"/></td>
          <td><xsl:value-of select="vbr"/></td>
        </tr>
        </xsl:for-each>
      </table>
    </xsl:element>
</xsl:template>

<xsl:template name="highlighter">
  <td>
    <xsl:if test="../../artist/displayname != artist/displayname">
    <xsl:attribute name="class">fadeout</xsl:attribute>
    abc
  </xsl:if>
  </td>
</xsl:template>

<xsl:template name="page_footer">
  <hr/>
</xsl:template>

</xsl:stylesheet>
-------[END SOURCE XSL]--------



-------[BEGIN SOURCE XML]--------
<?xml version="1.0"?>
<mp3info creationdate="24/10/2004 11:18:52">
  <mp3list>
    <mp3>
      <title>Why Go</title>
      <album>
        <displayname>Ten</displayname>
      </album>
      <artist>
        <displayname>Pearl Jam</displayname>
      </artist>
      <year>
        <displayname>1992</displayname>
      </year>
      <genres>
        <genre>
          <displayname>Grunge</displayname>
        </genre>
      </genres>
      <trackindex>1</trackindex>
    </mp3>
    <mp3>
      <title>Black</title>
      <album>
        <displayname>Ten</displayname>
      </album>
      <artist>
        <displayname>Pearl Jam</displayname>
      </artist>
      <year>
        <displayname>1992</displayname>
      </year>
      <genres>
        <genre>
          <displayname>Grunge</displayname>
        </genre>
      </genres>
      <trackindex>2</trackindex>
    </mp3>
    <mp3>
      <title>Silver Dawn</title>
      <album>
        <displayname>Earth Volume 2</displayname>
      </album>
      <artist>
        <displayname>Artemis</displayname>
      </artist>
      <year>
        <displayname>1997</displayname>
      </year>
      <genres>
        <genre>
          <displayname>Drum &amp; Bass</displayname>
        </genre>
      </genres>
      <trackindex>2</trackindex>
    </mp3>
    <mp3>
      <title>Artifical Life</title>
      <album>
        <displayname>Earth Volume 2</displayname>
      </album>
      <artist>
        <displayname>Odyssey</displayname>
      </artist>
      <year>
        <displayname>1997</displayname>
      </year>
      <genres>
        <genre>
          <displayname>Drum &amp; Bass</displayname>
        </genre>
      </genres>
      <trackindex>3</trackindex>
    </mp3>
    <mp3>
      <title>Fictions</title>
      <album>
        <displayname>Earth Volume 2</displayname>
      </album>
      <artist>
        <displayname>Rollercone</displayname>
      </artist>
      <year>
        <displayname>1997</displayname>
      </year>
      <genres>
        <genre>
          <displayname>Drum &amp; Bass</displayname>
        </genre>
      </genres>
      <trackindex>1</trackindex>
    </mp3>
  </mp3list>
</mp3info>
-------[END SOURCE XML]--------

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.