﻿<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
	version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:ufcpp="http://ufcpp.net/study/document"
  >

<!--
インデックスページのドキュメントルート index の処理。
-->

<!-- ********** インデックス用 ********** -->
<xsl:template match="/ufcpp:index">
<html lang="ja-JP">

<head>
<meta http-equiv="Content-Language" content="ja-JP" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta name="Author" content="IWANAGA Nobuyuki" />

<xsl:if test="@keyword!=''">
  <meta name="keywords" content="{@keyword}"/>
</xsl:if>
<xsl:if test="@description!=''">
  <meta name="description" content="{@description}"/>
</xsl:if>

<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />

<link rel="stylesheet" href="../main.css" />
<link rel="stylesheet" href="../index.css" />

<!-- ドキュメントごとのスタイルシート指定 -->
<xsl:for-each select="ufcpp:css">
  <link rel="stylesheet">
  <xsl:attribute name="href"><xsl:value-of select="@name"/>.css</xsl:attribute>
  </link>
</xsl:for-each>

<title><xsl:value-of select="/ufcpp:index/@title" /></title>

</head>
<body>

<!-- ↓インデックスページヘッダ -->
<div class="CommonHeader">
  <xsl:variable name="commonih" select="document('common/iheader')" />
  <xsl:apply-templates select="$commonih/content/*"/>
</div>
<!-- ↑インデックスページヘッダ -->

<h1><xsl:value-of select="/ufcpp:index/@title" /></h1>

<xsl:apply-templates select="ufcpp:summary"/>

<xsl:call-template name="MakeDocIndex">
 <xsl:with-param name="root" select="/ufcpp:index"/>
</xsl:call-template>

<p>
<xsl:if test="/ufcpp:index/@since!=''">
Since: <xsl:value-of select="/index/@since" />.
</xsl:if>
<xsl:if test="/ufcpp:index/@update!=''">
 Last Update: <xsl:value-of select="/ufcpp:index/@update" />.
</xsl:if>
</p>

<p class="footer">
<a href="../index.html" accesskey="i">インデックスに戻る(<span class="accesskey">i</span>)</a>
</p>

<!-- ↓インデックスページフッタ -->
<div class="CommonHeader">
  <xsl:apply-templates select="/ufcpp:index/ufcpp:IAds/*"/>
  <xsl:variable name="commonif" select="document('common/ifooter')" />
  <xsl:apply-templates select="$commonif/content/*"/>
</div>
<!-- ↑インデックスページフッタ -->

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
<xsl:text> </xsl:text>
</script>
<script type="text/javascript">
<![CDATA[
_uacct = "UA-887343-1";
urchinTracker();
]]>
</script>

</body>
</html>
</xsl:template>

<!-- この分野のサマリー -->
<xsl:template match="/ufcpp:index/ufcpp:summary">
<xsl:apply-templates select="*"/>
</xsl:template>

<!-- この分野のドキュメント一覧を ul 形式で列挙。 -->
<xsl:template name="MakeDocIndex">
  <xsl:param name="root" select="/ufcpp:index"/>
  <xsl:param name="class" select="'index'"/>

<ul>
  <xsl:attribute name="class">
    <xsl:value-of select="$class"/>
  </xsl:attribute>
<xsl:apply-templates select="$root/ufcpp:document|$root/ufcpp:section|$root/ufcpp:extern"/>
</ul>
</xsl:template>

<!-- この分野のドキュメントを li 形式で表示。 -->
<xsl:template match="ufcpp:index//ufcpp:document">
	<xsl:variable name="xmlname" select="concat($dir,'/',@href,'.xml')" />
	<xsl:variable name="htmlname" select="concat('../',$dir,'/',@href,'.html')" />

	<li class="indexDoc">
	<a href="{$htmlname}">
	<xsl:value-of select="document($xmlname)/ufcpp:document/@title" />
	</a>
	</li>
</xsl:template>

<!-- 外部へのリンクを li 形式で表示。 -->
<xsl:template match="ufcpp:index//ufcpp:extern">
  <li class="indexDoc">
	<a href="{@href}">
	<xsl:value-of select="@title" />
	</a>
	</li>
</xsl:template>

<!-- 分野をセクション分け。再起的に MakeDocIndex を呼び出し。 -->
<xsl:template match="ufcpp:index//ufcpp:section">
<li class="indexSection">
<xsl:if test="@title!=''">
	<xsl:variable name="id">
		<xsl:choose>
		<xsl:when test="@id!=''"><xsl:value-of select="@id"/></xsl:when>
		<xsl:otherwise><xsl:value-of select="generate-id()"/></xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
  <h2 class="indexSection"><a id="{$id}"><xsl:value-of select="@title"/></a></h2>
</xsl:if>
 <xsl:call-template name="MakeDocIndex">
   <xsl:with-param name="root" select="."/>
 </xsl:call-template>
</li>
</xsl:template>

</xsl:stylesheet>
