<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fn="http://www.w3.org/2005/xpath-functions"
        xmlns:l="http://castopulence.org/2011/09/lyrics">
    <xsl:output
            method="xml"
            omit-xml-declaration="no"
            version="1.0"
            doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
            indent="yes"
            media-type="applicaion/xhtml+xml"
            />
    <xsl:template match="/l:lyrics">
       <html>
            <head>
                <meta http-equiv="Content-Type"
                        content="text/html; charset=utf-8" />
                <title>
                    <xsl:text>Castopulence Software - Lyrics</xsl:text>
                </title>
                <link href="theme/jquery-ui-1.8.custom.css"
                        rel="stylesheet" type="text/css" />
                <link href="lyrics.css" rel="stylesheet"
                        type="text/css" />
            </head>
            <body>
                <h1>Lyrics</h1>
                <p>The following page is an XSL transformation of XML
                        song lyric data that I transcribed. I'm personally
                        just sick of wanting to sing along with a song and
                        having to trip over wrong lyrics online. I don't
                        always know every word, but I think I make fewer
                        mistakes than any of the popular lyrics sites do.
                        In any case, note that I don't claim any copyright
                        on the lyrics in the source XML document, nor on the
                        transformed XHTML result, unless otherwise
                        specified. The lyrics are copyright of their
                        respective copyright owners.</p>
                <p>The 'title' attribute of slang words contains
                        my "translation" AKA expanded meaning. Most
                        graphical browsers will reveal the title attribute
                        as a tooltip when you hover over the element on
                        the page. If you have trouble understanding a
                        particular slang word on this page give it a try
                        to see what [I believe] it means. Only the first
                        alternative is shown, however, so you'll have to
                        view the XML or XHTML source code to see other
                        alternatives.</p>
                <p>If you are or represent a copyright owner for a work
                        that is published on this site and would like it
                        removed or otherwise marked up then please kindly
                        contact the site owner, Brandon McCaig, by E-mail
                        (bamccaig at castopulence dot org); detailing who
                        you are, what your relationship to the copyright
                        owner is, and what the copyright owner's wishes
                        are. We will promptly do as requested, whether
                        that means adding special markup or disclaimers,
                        or locking the work in question up behind a
                        secured connection for personal use. We appreciate
                        your pardon.</p>
                <h2>Index</h2>
                <ul class="index">
                    <xsl:apply-templates select="l:song" mode="index" />
                </ul>
                <xsl:apply-templates select="*" />
                <div>
                    <h2>Reuse</h2>
                    <p><strong>Can I freely and openly use the DTD, XSL,
                            CSS, or XHTML code found on this site?</strong></p>
                    <p>You may use and modify it for personal or free /
                            open use, meaning that you'll give it away
                            for free without requiring registration to
                            your site (free or otherwise), subscription or
                            membership fees, or licensing fees.</p>
                    <p>If you wish to use them with a restricted access or
                            paid-for product or service then I insist that
                            you contact me for explicit permission, which
                            may or may not involve a licensing fee on a
                            per use basis, depending on the specifics of
                            your use.</p>
                    <p>Keep in mind that this does <strong>NOT</strong>
                            include the actual lyrics embedded within the
                            code, whose use is under the control of each
                            work's respective copyright owner. If the
                            lyrics were written by me, Brandon McCaig,
                            then I'd probably be willing to give you
                            permission to publish my lyrics, assuming that
                            you do so freely and openly and without
                            misrepresenting the authorship or copyright
                            owner. Feel free to ask to make sure.</p>
                </div>
            </body>
        </html> 
    </xsl:template>
    <xsl:template mode="index" match="l:song">
        <li class="song">
            <a>
                <xsl:attribute name="href">
                    <xsl:text>#song-</xsl:text>
                    <xsl:value-of select="position()" />
                </xsl:attribute>
                <span class="artist">
                    <xsl:value-of select="l:artist/text()" />
                </span>
                <xsl:if test="string-length(l:album) &gt; 0">
                    /
                    <span class="album">
                        <xsl:value-of select="l:album/text()" />
                    </span>
                </xsl:if>
                <span class="title">
                    /
                    <xsl:value-of select="l:title/text()" />
                <xsl:if test="string-length(l:version) &gt; 0">
                    <span class="version">
                        (<xsl:value-of select="l:version/text()" />)
                    </span>
                </xsl:if>
                </span>
            </a>
        </li>
    </xsl:template>
    <xsl:template match="l:song">
        <div class="song">
            <xsl:attribute name="id">
                <xsl:text>song-</xsl:text>
                    <xsl:value-of select="position()" />
            </xsl:attribute>
            <h2>Song</h2>
            <div class="header">
                <div class="artists">
                    <div class="label">Artist:</div>
                    <ul class="artists">
                        <xsl:apply-templates select="l:artist" />
                    </ul>
                    <xsl:if test="count(l:featured-artist) &gt; 0">
                        featuring
                        <ul class="featured-artists">
                            <xsl:apply-templates select="l:featured-artist" />
                        </ul>
                    </xsl:if>
                </div>
                <xsl:apply-templates select="l:album" />
                <xsl:apply-templates select="l:title" />
                <xsl:apply-templates select="l:version" />
                <xsl:apply-templates select="l:copyright" />
                <xsl:apply-templates select="l:notes" />
            </div>
            <xsl:apply-templates select="l:lyric" />
        </div>
    </xsl:template>
    <xsl:template match="l:song/l:artist">
        <li class="artist">
            <xsl:value-of select="text()" />
        </li>
    </xsl:template>
    <xsl:template match="l:song/l:featured-artist">
        <li class="artist">
            <xsl:value-of select="text()" />
        </li>
    </xsl:template>
    <xsl:template match="l:song/l:album">
        <div class="album">
            <div class="label">Album:</div>
            <span class="album">
                <xsl:value-of select="text()" />
            </span>
        </div>
    </xsl:template>
    <xsl:template match="l:song/l:title">
        <div class="title">
            <div class="label">Title:</div>
            <span class="title">
                <xsl:value-of select="text()" />
            </span>
        </div>
    </xsl:template>
    <xsl:template match="l:song/l:version">
        <div class="version">
            <div class="label">Version:</div>
            <span class="version">
                <xsl:value-of select="text()" />
            </span>
        </div>
    </xsl:template>
    <xsl:template match="l:song/l:copyright">
        <div class="copyright">
            <div class="label">Copyright:</div>
            <span class="copyright">
                <xsl:value-of select="text()" />
            </span>
        </div>
    </xsl:template>
    <xsl:template match="l:song/l:notes">
        <div class="notes">
            <div class="label">Notes:</div>
            <span class="notes">
                <xsl:value-of select="text()" />
            </span>
        </div>
    </xsl:template>
    <xsl:template match="l:song/l:lyric">
        <div class="lyric">
            <xsl:apply-templates select="*" />
        </div>
    </xsl:template>
    <xsl:template match="l:lyric/l:intro">
        <div class="intro">
            <h3>Intro</h3>
            <xsl:apply-templates select="*" />
        </div>
    </xsl:template>
    <xsl:template match="l:lyric/l:verse">
        <div class="verse">
            <h3>Verse</h3>
            <xsl:apply-templates select="*" />
        </div>
    </xsl:template>
    <xsl:template match="l:lyric/l:prechorus">
        <div class="prechorus">
            <xsl:attribute name="id">
                <xsl:text>prechorus-</xsl:text>
                <xsl:choose>
                    <xsl:when test="string-length(@version) &gt; 0">
                        <xsl:value-of select="@version" />
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>master</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:attribute>
            <h3>Prechrous</h3>
            <xsl:apply-templates select="*" />
        </div>
    </xsl:template>
    <xsl:template match="l:lyric/l:chorus">
        <div class="chorus">
            <xsl:attribute name="id">
                <xsl:text>chorus-</xsl:text>
                <xsl:choose>
                    <xsl:when test="string-length(@version) &gt; 0">
                        <xsl:value-of select="@version" />
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>master</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:attribute>
            <h3>Chorus</h3>
            <xsl:apply-templates select="*" />
        </div>
    </xsl:template>
    <xsl:template match="l:lyric/l:repeat-prechorus">
        <div class="repeat-prechorus">
            <h3>
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>#prechorus-</xsl:text>
                        <xsl:choose>
                            <xsl:when test="string-length(@version) &gt; 0">
                                <xsl:value-of select="@version" />
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:text>master</xsl:text>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:attribute>
                    Repeat Prechorus
                    <xsl:if test="number(@l:count)">
                        (x<xsl:value-of select="@l:count" />)
                    </xsl:if>
                </a>
            </h3>
        </div>
    </xsl:template>
    <xsl:template match="l:lyric/l:repeat-chorus">
        <div class="repeat-chorus">
            <h3>
                <a>
                    <xsl:attribute name="href">
                        <xsl:text>#chorus-</xsl:text>
                        <xsl:choose>
                            <xsl:when test="string-length(@version) &gt; 0">
                                <xsl:value-of select="@version" />
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:text>master</xsl:text>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:attribute>
                    Repeat Chorus
                    <xsl:if test="number(@l:count)">
                        (x<xsl:value-of select="@l:count" />)
                    </xsl:if>
                </a>
            </h3>
        </div>
    </xsl:template>
    <xsl:template match="l:lyric/l:outro">
        <div class="outro">
            <h3>Outro</h3>
            <xsl:apply-templates select="*" />
        </div>
    </xsl:template>
    <xsl:template match="l:intro/l:line|l:verse/l:line|l:prechorus/l:line|l:chorus/l:line|l:outro/l:line">
        <div class="line">
            <xsl:apply-templates select="l:mumble|l:censored|l:cuss|l:slang|l:sound|node()" />
            <br />
        </div>
    </xsl:template>
    <xsl:template match="l:line/l:mumble">
        <span class="mumble">
            <xsl:apply-templates select="*|node()" />
        </span>
    </xsl:template>
    <xsl:template match="l:mumble/l:what">
        <span class="what-icon">??</span>
        <span class="what">
            <xsl:value-of select="text()" />
        </span>
        <span class="what-icon">??</span>
    </xsl:template>
    <xsl:template match="l:line/l:censored">
        <div class="censored">
            <span class="sounds-like">
                <xsl:value-of select="l:sounds-like/text()" />
            </span>
            <span class="actual">
                <xsl:value-of select="l:actual/text()" />
            </span>
        </div>
    </xsl:template>
    <xsl:template match="l:line/l:cuss">
        <span class="cuss">
            <xsl:value-of select="text()" />
        </span>
    </xsl:template>
    <xsl:template match="l:line/l:slang">
        <span class="slang">
            <xsl:if test="count(l:alternative) &gt; 0">
                <xsl:attribute name="title">
                    <xsl:value-of select="l:alternative" />
                </xsl:attribute>
            </xsl:if>
            <xsl:apply-templates class="*" />
        </span>
    </xsl:template>
    <xsl:template match="l:slang/l:literal">
        <span class="literal">
            <xsl:value-of select="text()" />
        </span>
    </xsl:template>
    <xsl:template match="l:slang/l:alternative">
        <span class="alternative">
            <xsl:value-of select="text()" />
        </span>
    </xsl:template>
    <xsl:template match="l:sound">
        <div class="sound">
            (**
            <span class="sound">
                <xsl:value-of select="text()" />
            </span>
            **)
        </div>
    </xsl:template>
    <xsl:template match="*">
        <xsl:value-of select="text()" />
    </xsl:template>
</xsl:stylesheet>


