<?xml version="1.0"?>
<xsl:stylesheet
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:bib="http://joachim-breitner.de/2004/Website/Bibliography"
  version="1.0"
>

<!-- This file is © 2004 Joachim Breitner. All Rights Reserved, but feel free to ask for a Free Licence (MIT, GPL): mail@joachim-breitner.de -->

<!--
<xsl:output method="xml"
  media-type="text/html"
  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
/>
-->

<xsl:template match="bib:bibliography">
 <ul class="bibliography">
  <xsl:apply-templates/>
 </ul>
</xsl:template>

<xsl:template match="bib:bibentry">
 <li>
  <span class="type">
   <xsl:choose>
    <xsl:when test="@type = 'diplomathesis'">
     <xsl:value-of select="$lang.diplomathesis"/>
    </xsl:when>
    <xsl:when test="@type = 'doctoralthesis'">
     <xsl:value-of select="$lang.doctoralthesis"/>
    </xsl:when>
    <xsl:when test="@type = 'studentresearchproject'">
     <xsl:value-of select="$lang.studentresearchproject"/>
    </xsl:when>
    <xsl:when test="@type = 'magazine'">
     <xsl:value-of select="$lang.magazine"/>
    </xsl:when>
    <xsl:when test="@type = 'talk'">
     <xsl:value-of select="$lang.talk"/>
    </xsl:when>
    <xsl:when test="@type = 'tutorial'">
     <xsl:value-of select="$lang.tutorial"/>
    </xsl:when>
    <xsl:when test="@type = 'guestlecture'">
     <xsl:value-of select="$lang.guestlecture"/>
    </xsl:when>
    <xsl:when test="@type = 'preprint'">
     <xsl:value-of select="$lang.preprint"/>
    </xsl:when>
    <xsl:when test="@type = 'paper'">
     <xsl:value-of select="$lang.paper"/>
    </xsl:when>
    <xsl:when test="@type = 'journal-paper'">
     <xsl:value-of select="$lang.journalpaper"/>
    </xsl:when>
    <xsl:when test="@type = 'conference-paper'">
     <xsl:value-of select="$lang.conferencepaper"/>
    </xsl:when>
    <xsl:when test="@type = 'workshop-paper'">
     <xsl:value-of select="$lang.workshoppaper"/>
    </xsl:when>
    <xsl:when test="@type = 'bookchapter'">
     <xsl:value-of select="$lang.bookchapter"/>
    </xsl:when>
    <xsl:when test="@type = 'isabelle'">
     <xsl:value-of select="$lang.isabelle"/>
    </xsl:when>
    <xsl:when test="@type = 'book'">
     <xsl:value-of select="$lang.book"/>
    </xsl:when>
    <xsl:when test="@type = 'podcast'">
     <xsl:value-of select="$lang.podcast"/>
    </xsl:when>
   </xsl:choose>
  </span>
  <xsl:apply-templates select="*"/>
 </li>
</xsl:template>

<xsl:template name="comma">
 <xsl:if test="position()!=last()">
  <xsl:text>, </xsl:text>
 </xsl:if>
</xsl:template>

<xsl:template match="bib:sub">
 <sub><xsl:apply-templates /></sub>
</xsl:template>

<xsl:template match="bib:title">
 <strong><xsl:apply-templates /></strong>
</xsl:template>

<xsl:template match="bib:subtitle">
 <em><xsl:apply-templates /></em>
</xsl:template>

<!-- variant with me
<xsl:template match="bib:authors">
 <span class="coauthors">
  <xsl:value-of select="$lang.by" />
  <xsl:text> </xsl:text>
  <xsl:for-each select="*">
   <xsl:apply-templates select="."/>
   <xsl:if test="position() != last()">
      <xsl:text>, </xsl:text>
   </xsl:if>
  </xsl:for-each>
 </span>
</xsl:template>
 -->

<!-- variant with with -->
<xsl:template match="bib:authors">
 <span class="coauthors">
  <xsl:value-of select="$lang.with" />
  <xsl:text> </xsl:text>
  <xsl:for-each select="*[not(self::bib:me)]">
   <xsl:apply-templates select="."/>
   <xsl:choose>
    <xsl:when test="position() &lt; last()-1">
     <xsl:text>, </xsl:text>
    </xsl:when>
    <xsl:when test="position() = last()-1">
     <xsl:text> &amp; </xsl:text>
    </xsl:when>
   </xsl:choose>
  </xsl:for-each>
 </span>
</xsl:template>

<xsl:template match="bib:coauthor">
 <xsl:apply-templates />
</xsl:template>

<xsl:template match="bib:me">
 <xsl:text>me</xsl:text>
</xsl:template>

<xsl:template match="bib:year">
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:date">
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:event">
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:place">
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:school">
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:note">
 <span style="font-style:italic">
  <xsl:apply-templates />
 </span>
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:book">
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:journal">
 <xsl:if test="@status = 'submitted'">
  <xsl:value-of select="$lang.submitted-to"/>
  <xsl:text> </xsl:text>
 </xsl:if>
 <xsl:if test="@status = 'accepted'">
  <xsl:value-of select="$lang.accepted-by"/>
  <xsl:text> </xsl:text>
 </xsl:if>
 <xsl:if test="@status = 'conditionally accepted'">
  <xsl:value-of select="$lang.conditionally-accepted-by"/>
  <xsl:text> </xsl:text>
 </xsl:if>
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:issue">
 <xsl:value-of select="$lang.issue"/>
 <xsl:text> </xsl:text>
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:episode">
 <xsl:value-of select="$lang.episode"/>
 <xsl:text> </xsl:text>
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:volume">
 <xsl:value-of select="$lang.volume"/>
 <xsl:text> </xsl:text>
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:pages">
 <xsl:choose>
  <xsl:when test="string(number(.))='NaN'">
   <xsl:value-of select="$lang.pages"/>
  </xsl:when>
  <xsl:otherwise>
   <xsl:value-of select="$lang.page"/>
  </xsl:otherwise>
 </xsl:choose>
 <xsl:text> </xsl:text>
 <xsl:apply-templates />
 <xsl:call-template name="comma"/>
</xsl:template>

<xsl:template match="bib:references">
 <div>
 <xsl:for-each select="*">
  <xsl:if test="position() != 1">
     <xsl:text> • </xsl:text>
  </xsl:if>
  <xsl:apply-templates select="."/>
 </xsl:for-each>
 </div>
</xsl:template>

<xsl:template match="bib:pdf-file">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.pdfFile"/>
 </a>
</xsl:template>

<xsl:template match="bib:handout">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.handout"/>
 </a>
</xsl:template>

<xsl:template match="bib:slides">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.slides"/>
 </a>
</xsl:template>

<xsl:template match="bib:transcript">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.transcript"/>
 </a>
</xsl:template>

<xsl:template match="bib:latex-file">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.latexSource"/>
 </a>
</xsl:template>

<xsl:template match="bib:blog-entry">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.blogEntry"/>
 </a>
</xsl:template>

<xsl:template match="bib:video-stream">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.videoStream"/>
 </a>
</xsl:template>

<xsl:template match="bib:online-article">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.onlineArticle"/>
 </a>
</xsl:template>

<xsl:template match="bib:event-program">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.eventProgram"/>
 </a>
</xsl:template>

<xsl:template match="bib:eprint">
 <xsl:value-of select="$lang.preprint"/><xsl:text>: </xsl:text>
 <a>
  <xsl:attribute name="href">http://eprint.iacr.org/<xsl:value-of select="." /></xsl:attribute>
  ePrint:<xsl:value-of select="." />
 </a>
</xsl:template>

<xsl:template match="bib:arxiv">
 <xsl:value-of select="$lang.preprint"/><xsl:text>: </xsl:text>
 <a>
  <xsl:attribute name="href">http://arxiv.org/abs/<xsl:value-of select="." /></xsl:attribute>
  arXiv:<xsl:value-of select="." />
 </a>
</xsl:template>

<xsl:template match="bib:doi">
  <xsl:value-of select="$lang.doi"/><xsl:text>: </xsl:text>
 <a>
  <xsl:attribute name="href">http://dx.doi.org/<xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="." />
 </a>
</xsl:template>

<xsl:template match="bib:journal-page">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.journalPage"/>
 </a>
</xsl:template>

<xsl:template match="bib:homepage">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.homepage"/>
 </a>
</xsl:template>

<xsl:template match="bib:website">
 <a>
  <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.website"/>
 </a>
</xsl:template>

<xsl:template match="bib:d-nb">
 <a>
  <xsl:attribute name="href">http://d-nb.info/<xsl:value-of select="." /></xsl:attribute>
  <xsl:value-of select="$lang.d-nb"/>
 </a>
</xsl:template>


</xsl:stylesheet>
