<?xml version="1.0" encoding="Shift_JIS" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:variable name="days">
	<item>Mon</item>
	<item>Tue</item>
	<item>Wed</item>
	<item>Thu</item>
	<item>Fri</item>
	<item>Sat</item>
</xsl:variable>
<xsl:variable name="jikan">
	<item time="8:45-9:35">1</item>
	<item time="9:45-10:35">2</item>
	<item time="10:45-11:35">3</item>
	<item time="11:45-12:35">4</item>
	<item time="13:20-14:10">5</item>
	<item time="14:20-15:10">6</item>
</xsl:variable>

<xsl:template match="/">
	<xsl:apply-templates select="doc" />
</xsl:template>

<xsl:template name="styles">
   	<xsl:comment>
   		以下の font-family でフォントの指定、
        font-size でフォントサイズの指定
        td.wh 中の width, height でセルのサイズを
        指定する。（フォントサイズや
        セルに入る文字数を考えて指定すれば良い。）
    </xsl:comment>
  	td.wh{width="78";height="62";}
   	td{text-align:center; font-family: "ＭＳ 明朝" ; font-size : 18 pt;}
  	th{text-valign:center; text-align:center; background-color:#DDDDDD; font-family: "ＭＳ ゴシック" ; font-size : 20 pt;}
    th.left_top{width:30; height:50}
  	.title{font-family: "ＭＳ ゴシック" ; font-size : 20 pt; margin-bottom:10}
  	.break{page-break-after : always ;}
</xsl:template>

<xsl:template match="doc">
	<HTML>
		<HEAD>
			<TITLE>時間割表</TITLE>
            <style type="text/css">
            	<xsl:call-template name="styles"/>
            </style>
		</HEAD>
		<BODY>
			<xsl:apply-templates select="page"/>
        </BODY>
	</HTML>
</xsl:template>

<xsl:template match="page">
	<xsl:variable name="page">
		<xsl:copy-of select="day"/>
	</xsl:variable>
	<div class="title"><xsl:value-of select="title" /></div>
    <table border="1" cellspacing="0">
    <col font="bold-style" />
    	<tr>
        	<th class="left_top"><br /></th>
			<xsl:for-each select="msxsl:node-set($days)/item">
				<th><xsl:value-of select="."/></th>
			</xsl:for-each>
        </tr>
        
        <xsl:for-each select="msxsl:node-set($jikan)/item">
        	<tr>
        		<th>
        			<xsl:value-of select="."/>
        			<xsl:if test="@time!=''">
        				<br/><span style="font-size:10pt">
        				<xsl:value-of select="@time"/>
        				</span><br/>
        			</xsl:if>
        		</th>
        		<xsl:apply-templates select="msxsl:node-set($page)//day/item[position()=current()]"/>
        	</tr>
        </xsl:for-each>
    </table>
    <div style="line-height:150%">
    	<xsl:apply-templates select="desc" />
    </div>
    <xsl:if test="../page[1]"><div class="break"><br/></div></xsl:if>
</xsl:template>

<xsl:template match="item">
	<td class="wh">
	    <xsl:apply-templates select="text()|br" />
        <xsl:if test=".=''"><br/></xsl:if>
    </td>
</xsl:template>

<xsl:template match="desc">
	<xsl:copy-of select="@*|node()|*"/>
</xsl:template>

</xsl:stylesheet>
