File: songlist-to-xhtml.xsl

package info (click to toggle)
performous 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,748 kB
  • ctags: 2,894
  • sloc: cpp: 14,729; sh: 275; objc: 245; makefile: 102; xml: 14
file content (61 lines) | stat: -rw-r--r-- 2,446 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?xml version="1.0"?>

<!-- Use xmlstarlet tr songlist-to-xhtml.xsl songlist.xml > songlist.xhtml -->

<xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">

<xsl:output method="xml" indent="yes" encoding="UTF-8"/>

<xsl:template match="/songlist">
  <html>
    <head>
      <title>Karaoke</title>
      <meta http-equiv="Content-type" content="application/xhtml+xml; charset=UTF-8"/>
      <style>
    	body { font-size: xx-small; font-family: sans; }
    	tr { overflow: auto; }
    	th { text-align: left; }
    	td { white-space: pre; overflow: hidden; }
        #layout { border-spacing: 10mm; }
        table { float: left; margin: 3mm; table-layout: fixed; width: 46%; border: 2px solid black; border-collapse: collapse; }
        th:first-child, td:first-child { text-align: right; width: 5ex; }
        th, td { padding: 2px; padding-left: 3mm; padding-right: 3mm; }
        table th { background: black; color: white; border-bottom: 2px solid black; }
        #byArtist tr.fifth { background: #ddf; }
        #byTitle tr.fifth { background: #cfc; }
      </style>
    </head>
    <body>
            <table id="byArtist">
              <thead>
                <tr><th>#</th><th>Artist</th><th>Title</th></tr>
              </thead>
              <tbody>
                <xsl:for-each select="song">
                  <tr>
                    <xsl:if test="position() mod 5 = 0"><xsl:attribute name="class">fifth</xsl:attribute></xsl:if>
                    <td><xsl:value-of select="@num"/></td><td><xsl:value-of select="artist"/></td><td><xsl:value-of select="title"/></td>
                  </tr>
                </xsl:for-each>
              </tbody>
            </table>
            <table id="byTitle">
              <thead>
                <tr><th>#</th><th>Title</th><th>Artist</th></tr>
              </thead>
              <tbody>
                <xsl:for-each select="song">
                  <xsl:sort select="collate/title"/>
                  <tr>
                    <xsl:if test="position() mod 5 = 0"><xsl:attribute name="class">fifth</xsl:attribute></xsl:if>
                    <td><xsl:value-of select="@num"/></td><td><xsl:value-of select="title"/></td><td><xsl:value-of select="artist"/></td>
                  </tr>
                </xsl:for-each>
              </tbody>
            </table>
    </body>
  </html>
</xsl:template>

</xsl:stylesheet>