<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:anoh="http://anoh.s10.xrea.com/gwml"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:book="http://anoh.s10.xrea.com/book"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="xlink anoh book"
>

<!--変換内容-->

<!--XML宣言はPHPで作成するため出力不要-->
<xsl:output method="xml"
	version="1.0"
	encoding="utf-8"
	omit-xml-declaration="yes"
	indent="yes"
 />


<!--root以下にテンプレートを適用-->
<xsl:template match="/">
	<xsl:processing-instruction name="php">require("../common/content-head.inc");</xsl:processing-instruction>
	<html xml:lang="ja">
	<head>
		<xsl:processing-instruction name="php">require("../common/content-type.inc");</xsl:processing-instruction>
		<xsl:processing-instruction name="php">require("../common/head.inc");</xsl:processing-instruction>
		<title><xsl:value-of select="/anoh:doc/anoh:head/anoh:title" /><xsl:text>・</xsl:text><xsl:value-of select="/anoh:doc/anoh:head/anoh:month" /></title>
		<link rel="prev"><xsl:attribute name="href"><xsl:value-of select="anoh:doc/anoh:head/anoh:prev" /><xsl:text>.php</xsl:text></xsl:attribute></link>
		<xsl:if test="anoh:doc/anoh:head/anoh:month[@current ='no']"> <link rel="next"><xsl:attribute name="href"><xsl:value-of select="anoh:doc/anoh:head/anoh:next" /><xsl:text>.php</xsl:text></xsl:attribute></link></xsl:if>
		<xsl:for-each select="/anoh:doc/anoh:contents/anoh:day/anoh:section">
			<link rel="section">
				<xsl:attribute name="href"><xsl:text>#d</xsl:text><xsl:value-of select="../anoh:date" /><xsl:text>c</xsl:text><xsl:number level="multiple" count="anoh:section"/></xsl:attribute>
				<xsl:attribute name="title"><xsl:value-of select="anoh:ht" /></xsl:attribute>
			</link>
		</xsl:for-each>
	</head>
<body>

<div class="chead">
<p class="sub-catch"><a href="/">トップページ</a> &gt; <a href="/works/index.php">目次</a>  &gt; <xsl:value-of select="/anoh:doc/anoh:head/anoh:month" /> ： <a><xsl:attribute name="href"><xsl:value-of select="anoh:doc/anoh:head/anoh:prev" /><xsl:text>.php</xsl:text></xsl:attribute>前月</a><xsl:if test="anoh:doc/anoh:head/anoh:month[@current ='no']"> | <a><xsl:attribute name="href"><xsl:value-of select="anoh:doc/anoh:head/anoh:next" /><xsl:text>.php</xsl:text></xsl:attribute>翌月</a></xsl:if></p>

	<h1><xsl:value-of select="/anoh:doc/anoh:head/anoh:title" /></h1>
<!--アイコンパレードのインクルード-->
<xsl:processing-instruction name="php">require("../common/icon-parade.inc");</xsl:processing-instruction>

<address><xsl:processing-instruction name="php">require("../common/address.inc");</xsl:processing-instruction>　<xsl:processing-instruction name="php"> $file = filemtime(__FILE__);$time = date("D, d M Y G:i:s", $file);echo ("Last-Modified: $time JST");</xsl:processing-instruction></address>
</div>
	
<div class="cbody">
		<h1><a href="#latest"><xsl:value-of select="/anoh:doc/anoh:contents/anoh:day[last()]/anoh:section[position()=1]/anoh:ht" /></a></h1>
		<p class="content-description"><xsl:value-of select="/anoh:doc/anoh:contents/anoh:day[last()]/anoh:description" /></p>

	<!--その日のコンテンツをピックアップ-->
		<h2 class="todays-content">本日のコンテンツ一覧</h2>

	<ul class="backnumber" id="backnumber">
		<xsl:for-each select="/anoh:doc/anoh:contents/anoh:day[last()]/anoh:section"><li><a><xsl:attribute name="href"><xsl:text>#d</xsl:text><xsl:value-of select="../anoh:date" /><xsl:text>c</xsl:text><xsl:number value="position()" /></xsl:attribute><xsl:value-of select="anoh:ht" /></a></li></xsl:for-each>
	</ul>

<!--毎日の記事の処理-->
<xsl:for-each select="/anoh:doc/anoh:contents/anoh:day">
<div class="date">
	<xsl:if test="position()=last()">
		<xsl:attribute name="id">latest</xsl:attribute>
	</xsl:if>
	<xsl:apply-templates />
</div><xsl:comment>その日のコンテンツの終わり</xsl:comment>
</xsl:for-each><!--anoh:dateの終わり-->


</div><xsl:comment>cbodyの終了</xsl:comment>
<div class="cfoot">
	<p><a href="/semdata/update.php">最新記事一覧</a> | <a href="/documents/profile.php">プロフィール</a></p>
</div>

</body>
	</html>
</xsl:template>
<!--root以下のテンプレート終了-->

<!--各処理のテンプレート-->


<!--インライン要素-->
<xsl:template match="anoh:remark">
	<em class="tsukkomi"><xsl:text>＜</xsl:text><xsl:apply-templates /></em>
</xsl:template>

<xsl:template match="anoh:face">
	<span class="CharacterArt" title="anoh's face-character"><xsl:apply-templates /></span>
</xsl:template>

<xsl:template match="anoh:link">
	<a><xsl:attribute name="href"><xsl:value-of select="@xlink:href" /></xsl:attribute><xsl:attribute name="title"><xsl:value-of select="@xlink:title" /></xsl:attribute><xsl:apply-templates /></a>
	<xsl:choose>
		<xsl:when test="self::node()/@type='xml'"><img src="/common/xml.png" alt="【XML】" /></xsl:when>
		<xsl:when test="self::node()/@type='rdf'"><img src="/common/rdf.png" alt="【RDF】" /></xsl:when>
	</xsl:choose>

</xsl:template>

<xsl:template match="anoh:abbr">
	<abbr><xsl:attribute name="title"><xsl:value-of select="@title" /></xsl:attribute><xsl:apply-templates /></abbr>
</xsl:template>

<xsl:template match="anoh:quote">
	<q><xsl:attribute name="cite"><xsl:value-of select="@xlink:href" /></xsl:attribute><xsl:attribute name="title"><xsl:value-of select="@xlink:title" /></xsl:attribute><xsl:apply-templates /></q>
</xsl:template>

<xsl:template match="anoh:del">
	<del><xsl:attribute name="datetime"><xsl:value-of select="@datetime" /></xsl:attribute><xsl:apply-templates /></del>
</xsl:template>

<xsl:template match="anoh:ins">
	<ins><xsl:attribute name="datetime"><xsl:value-of select="@datetime" /></xsl:attribute><xsl:apply-templates /></ins>
</xsl:template>

<xsl:template match="anoh:image">
	<img><xsl:attribute name="src"><xsl:value-of select="@xlink:href" /></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="." /></xsl:attribute></img>
</xsl:template>

<!--ブロック要素-->
<xsl:template match="anoh:date">
	<h2><xsl:value-of select="." /></h2>
</xsl:template>

<xsl:template match="anoh:section">
	<xsl:for-each select="self::node()">
		<div class="section">
			<xsl:attribute name="id"><xsl:text>d</xsl:text><xsl:value-of select="../anoh:date" /><xsl:text>c</xsl:text><xsl:number level="single" count="anoh:section" /></xsl:attribute>
			<xsl:apply-templates />
		</div>
		<xsl:comment>記事の終わり</xsl:comment>
	</xsl:for-each>
</xsl:template>

<xsl:template match="anoh:ht">
	<h3><xsl:apply-templates /></h3>
</xsl:template>

<xsl:template match="anoh:p">
	<p><xsl:apply-templates /></p>
</xsl:template>

<xsl:template match="anoh:talk">
	<p><span class="talker"><xsl:value-of select="self::node()/@talker" /><xsl:text>　</xsl:text></span><xsl:apply-templates /></p>
</xsl:template>

<xsl:template match="anoh:caption">
	<p class="caption"><xsl:apply-templates /></p>
</xsl:template>

<xsl:template match="anoh:topic">
	<h4><xsl:apply-templates /></h4>
</xsl:template>

<xsl:template match="anoh:alone-image">
	<p class="alone-image"><xsl:apply-templates /></p>
</xsl:template>

<xsl:template match="anoh:blockquote">
	<blockquote><xsl:attribute name="cite"><xsl:value-of select="@xlink:href" /></xsl:attribute><xsl:attribute name="title"><xsl:value-of select="attribute::xlink:title" /></xsl:attribute><xsl:apply-templates /></blockquote>
</xsl:template>

<xsl:template match="anoh:dl">
		<h4><xsl:value-of select="self::node()/@title" /></h4>
		<dl class="talk">
			<dt><span class="talker"><xsl:value-of select="anoh:dt/@title" /><xsl:text>：</xsl:text></span><xsl:value-of select="anoh:dt" /></dt>
			<xsl:for-each select="anoh:dd">
				<dd><span class="talker"><xsl:value-of select="self::node()/@title" /><xsl:text>：</xsl:text></span><xsl:value-of select="self::node()" /></dd>
			</xsl:for-each>
		</dl>
</xsl:template>

<xsl:template match="anoh:relation">
<div class="relation">
	<h4>関連する記述</h4>
	<ul>
		<xsl:for-each select="anoh:link">
			<li><a><xsl:attribute name="href"><xsl:value-of select="@xlink:href" /></xsl:attribute><xsl:value-of select="self::node()"/></a><xsl:text>【</xsl:text><xsl:value-of select="@xlink:title"/><xsl:text>】</xsl:text></li>
		</xsl:for-each>
	</ul>
</div>
</xsl:template>

<xsl:template match="anoh:source">
	<div class="source">
		<h4><xsl:value-of select="self::node()/@title" /></h4>
		<ol><xsl:apply-templates /></ol>
	</div>
</xsl:template>


<xsl:template match="anoh:line">
	<xsl:for-each select="."><li><xsl:apply-templates /></li></xsl:for-each>
</xsl:template>


<xsl:template match="anoh:list[@type='book']">
	<div class="book">
		<xsl:apply-templates />
	</div>
</xsl:template>


<xsl:template match="anoh:list[@type='normal']">
	<xsl:if test="*[1][self::anoh:about]">
		<h4><xsl:value-of select="anoh:about"/></h4>
	</xsl:if>
	<ul>
		<xsl:for-each select="anoh:line">
			<li><xsl:apply-templates /></li>
		</xsl:for-each>
	</ul>
</xsl:template>

<xsl:template match="book:about">
	<h4><xsl:apply-templates /></h4>
</xsl:template>

<xsl:template match="anoh:about">
	<h4><xsl:apply-templates /></h4>
</xsl:template>

<xsl:template match="book:book">
	<dl><xsl:apply-templates /></dl>
</xsl:template>

<xsl:template match="book:title">
	<dt><xsl:apply-templates /></dt>
	<dd><ul>
			<li><xsl:text>ISBN</xsl:text><xsl:value-of select="following-sibling::book:isbn" /></li>
			<li><xsl:value-of select="following-sibling::book:publisher" /></li>
			<li><xsl:value-of select="following-sibling::book:author" /><xsl:text>著</xsl:text></li>
			<li><xsl:value-of select="following-sibling::book:price" /><xsl:text>円</xsl:text></li>
	</ul></dd>
	<xsl:for-each select="following-sibling::book:description/anoh:p">
		<dd><xsl:apply-templates /></dd>
	</xsl:for-each>
</xsl:template>

<xsl:template match="anoh:table">
	<table>
		<xsl:attribute name="class"><xsl:value-of select="self::node()/@type" /></xsl:attribute>
		<caption><xsl:value-of select="self::node()/@title" /></caption>
		<thead>
			<tr><xsl:for-each select="self::node()/anoh:thead/anoh:tr/anoh:th">
				<th><xsl:value-of select="self::node()" /></th>
			</xsl:for-each></tr>
		</thead>
		<tbody>
			<xsl:for-each select="self::node()/anoh:tbody/anoh:tr">
				<tr><xsl:call-template name="anoh:tr" /></tr>
			</xsl:for-each>
		</tbody>
	</table>
</xsl:template>

<xsl:template name="anoh:tr">
	<xsl:for-each select="anoh:td">
		<td><xsl:value-of select="self::node()" /></td>
	</xsl:for-each>
</xsl:template>

<!--以下処理が余ってしまった空のテンプレート-->
<xsl:template match="anoh:description"></xsl:template>
<xsl:template match="book:isbn"></xsl:template>
<xsl:template match="book:publisher"></xsl:template>
<xsl:template match="book:author"></xsl:template>
<xsl:template match="book:price"></xsl:template>
<xsl:template match="book:description"></xsl:template>

</xsl:stylesheet>