<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
		xmlns="http://www.w3.org/1999/xhtml"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="xml" version="1.0" encoding="iso-8859-1"
	      standalone="yes" indent="yes"
	      doctype-public="-//W3C//DTD XHTML 1.1//EN"
	      doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"/>
  
  <xsl:include href="misc.xsl"/>
  
  <xsl:template match="/">
    <xsl:variable name="year" select="/libris/info/year"/>
    
    <html xml:lang="sv">
      <head>
	<title>
	  <xsl:text>Rasmus Fantomenindex: </xsl:text>
	  <xsl:value-of select="$year"/>
	</title>
	<xsl:call-template name="baselinks"/>
        <xsl:for-each select="document('yset.xml')//year[. = $year]">
	  <xsl:if test="preceding-sibling::year[1]">
	    <link rel="First" href="{/yset/year[1]}" title="{/yset/year[1]}"/>
	    <link rel="Prev" href="{preceding-sibling::year[1]}"
		  title="{preceding-sibling::year[1]}"/>
	  </xsl:if>
	  <xsl:if test="following-sibling::year[1]">
	    <link rel="Next" href="{following-sibling::year[1]}"
		  title="{following-sibling::year[1]}"/>
	    <link rel="Last" href="{/yset/year[last()]}" 
		  title="{/yset/year[last()]}"/>
	  </xsl:if>
	</xsl:for-each>
      </head>
      
      <body id="y{$year}">
	<xsl:call-template name="topstuff"/>

        <xsl:apply-templates select="libris/info"/>
        
        <div class="floater">
          <h2>Issues</h2>
          <ul>
            <xsl:for-each select="libris/issue">
              <li><a href="#i{@nr}"><xsl:value-of select="@nr"/></a></li>
            </xsl:for-each>
          </ul>
        </div>
	<div class="main">
	  <xsl:apply-templates select="libris/issue"/>
	</div>
	
	<xsl:call-template name="trailer"/>
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="/libris/info">
    <div class="prematter">
      <xsl:apply-templates select="title"/>

      <xsl:if test="note">
        <div class="text">
          <xsl:apply-templates select="note"/>
        </div>
      </xsl:if>
    </div>
  </xsl:template>
  
  <xsl:template match="/libris/info/title">
    <h1>
      <xsl:apply-templates/>
      <xsl:text> </xsl:text>
      <xsl:value-of select="following-sibling::year"/>
    </h1>
  </xsl:template>

  <xsl:template match="/libris/info/note">
    <p><xsl:apply-templates/></p>
  </xsl:template>
  
  <xsl:template match="libris/issue">
    <div class="issue" id="i{@nr}">
      <h2 class="nr">Nr <xsl:value-of select="@nr"/></h2>
      <xsl:apply-templates/>
      <hr/>
    </div>
  </xsl:template>
  
  <xsl:template match="libris/issue/skick"><!-- ignore --></xsl:template>
  
  <xsl:template match="omslag">
    <p class="omslag">
      <img src="http://www.seriesam.com/pc/fantomen{../../info/year}{../@nr}.jpg"
	   alt="" class="omslag" title="Omslag {../@nr}, från seriesam.com"/>
      <xsl:text>Omslag</xsl:text>
      
      <xsl:if test="by">
        <xsl:text> av </xsl:text>
      <em>
	<xsl:choose>
	  <xsl:when test="by/who">
	    <xsl:apply-templates select="by"/>
	  </xsl:when>
	  <xsl:otherwise>
	    <xsl:call-template name="who-link"/>
	  </xsl:otherwise>
	</xsl:choose>
      </em>
      </xsl:if>
      <xsl:if test="best">
        <span>
          <xsl:attribute name="class">
            <xsl:if test="best/@plac &lt; 4">
              <xsl:text>medalj </xsl:text>
            </xsl:if>
            <xsl:text>plac</xsl:text>
            <xsl:value-of select="best/@plac"/>
          </xsl:attribute>
	  <span class="hash">, blev #</span>
	  <span class="plac"><xsl:value-of select="best/@plac"/></span>
	  <span class="sep">, </span>
	  <span class="text">
            <xsl:text>i Bästa Omslag </xsl:text>
	    <xsl:value-of select="/*/info/year"/>
	  </span>
	</span>
      </xsl:if>
      <xsl:text>.</xsl:text>
    </p>
  </xsl:template>
  
  <xsl:template match="serie">
    <div class="serie">
      <h3>
        <xsl:apply-templates mode="serieheadline"
                             select="label|title|episode[1]|part"/>
        <xsl:apply-templates mode="serieheadline" select="best"/>
      </h3>
      
      <xsl:call-template name="details"/>
    </div>
  </xsl:template>
  
  <xsl:template match="text">
    <div class="text">
      <h3>
        <xsl:apply-templates select="title|subtitle"/>
      </h3>
      
      <xsl:call-template name="details"/>
    </div>
  </xsl:template>
  
  <xsl:template match="text/subtitle">
    <xsl:text>: </xsl:text>
    <xsl:apply-templates/>
  </xsl:template>
</xsl:stylesheet>

