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

RE: compare out of context?

Subject: RE: compare out of context?
From: "Thomas Vanparys" <thomas.vanparys@xxxxxxxxxx>
Date: Tue, 2 Nov 2004 23:43:13 +0100
xsl compare
Hi again,

I found an answer: passing parameters in the template calls all the way down
to the point I need them.

I'm pretty sure my code looks aweful at this point but it works. If anyone
has any tips on how I could optimise the routine I'm all ears.

-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>
      <style>
          .header { font-size: larger; font-weight: bold; cursor: hand;
cursor:pointer;
                     background-color:#cccccc; font-family: Verdana; }
          .details { background-color:#eeeeee; font-family: Verdana; }
          .fadeout { color:#F0C2BB; }
      </style>
    </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:with-param name="passed_param">
              <xsl:value-of select="$top_artist"/>
            </xsl:with-param>
          </xsl:call-template>
        </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:param name="passed_param"/>
  <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">
          <xsl:with-param name="passed_param">
            <xsl:value-of select="$passed_param"/>
          </xsl:with-param>
        </xsl:call-template>
        <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">
  <xsl:param name="passed_param" select="'Default Data'"/>
  <xsl:if test="$passed_param != artist/displayname">
    <xsl:attribute name="class">fadeout</xsl:attribute>
  </xsl:if>
</xsl:template>

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

</xsl:stylesheet>

-------[END SOURCE XSL]--------

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.