<?xml version="1.0" encoding="EUC-JP"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns="http://www.w3.org/TR/REC-html40"
	xmlns:d="http://www.horobi.com/xmlns/diary"
	xmlns:log="http://www.horobi.com/xmlns/log"
	xmlns:b="http://www.horobi.com/xmlns/bib"
	xmlns:nav="http://www.horobi.com/xmlns/navigation"
	xmlns:l="http://www.horobi.com/xmlns/link"
	xmlns:n="http://www.horobi.com/xmlns/note"
	xmlns:e="http://www.horobi.com/xmlns/event"
	>
<xsl:output method="html" encoding="EUC-JP"/>

<xsl:template match="/">
  <html>
    <head><title>日記インデックス</title></head>
    <body bgcolor="#eeeecc">
      <table width="100%">
        <tr>
	  <td valign="bottom">
	    [一覧]<xsl:text> </xsl:text>
	    <a href="dindex-bib.html">[書籍索引]</a><xsl:text> </xsl:text>
	    <a href="dindex-auth.html">[作家索引]</a><xsl:text> </xsl:text>
	    <!--<a href="dindex-link.html">[リンク索引]</a><xsl:text> </xsl:text>-->
	  </td>
	  <td valign="bottom">
	    <font size="-2">
	    ※1999年4月以前の日記はインデックス化していません。
	    </font>
	  </td>
	  <td valign="top">
            <h1 align="right">
	      <font color="#5555cc">日記インデックス</font>
	    </h1>
	  </td>
        </tr>
      </table>
      <hr />
      <xsl:apply-templates select="/folder/file"/>
    </body>
  </html>
</xsl:template>

<xsl:template match="file">
  <xsl:apply-templates select="d:diary"/>
</xsl:template>

<xsl:template match="d:diary">
  <font color="#5555cc"><b><xsl:value-of select="d:heading"/></b></font>:
  <xsl:apply-templates select="log:logs">
    <xsl:sort select="@year" data-type="number" order="ascending" />
  </xsl:apply-templates>
  <hr />
</xsl:template>

<xsl:template match="log:logs">
  <xsl:text> </xsl:text><b><u><xsl:value-of select="@year"/></u>年</b>: 
  <xsl:apply-templates select="log:log">
    <xsl:sort select="substring-before(@date,'-')"
              data-type="number" order="ascending" />
    <xsl:sort select="substring-after(@date,'-')"
              data-type="number" order="ascending" />
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="log:log">
  <xsl:variable name="file" select="ancestor::file/@name"/>
  <xsl:if test="position()!=1"> / </xsl:if>
  <a href="{$file}.html#{@date}" target="diary">
    <font size="-2" color="#aa0000">
      <b>[<xsl:value-of select="@date"/>] </b>
    </font>
    <xsl:choose>
      <xsl:when test="log:sub">
        <xsl:apply-templates select="log:sub"/>
      </xsl:when>
      <xsl:when test="d:section">
        <font size="-1" color="#5555cc">
        <xsl:apply-templates select="d:section/d:subject"/>
	</font>
      </xsl:when>
      <xsl:otherwise>
      </xsl:otherwise>
    </xsl:choose>
  </a>
</xsl:template>

<xsl:template match="d:subject">
  <xsl:value-of select="."/>
  <xsl:if test="position()!=last()">/</xsl:if>
</xsl:template>

<xsl:template match="log:sub">
  <font size="-1" color="#5555cc">
    <xsl:value-of select="."/>
  </font>
</xsl:template>

<xsl:template match="log:sub[normalize-space(.)='']">
  <!--<font color="gray" size="-1">(無題)</font>-->
</xsl:template>

</xsl:stylesheet>
