<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output method="html"
				doctype-public="-//W3C//DTD HTML 4.01 //EN"
				doctype-system="http://www.w3.org/TR/html4/strict.dtd"
				encoding="UTF-8" />

	<xsl:template match="/DOC">
		<xsl:apply-templates select="BODY"/>
	</xsl:template>

	<xsl:template match="BODY">
	<html>

		<head>
			<title><xsl:value-of select="TITLE" /></title>
		</head>

		<body>
			<br/><br/>
			<font size="-1">
				<div align="right">
					<u><xsl:value-of select="DOCNO" /></u><br/>
					<br/>
					<xsl:apply-templates select="DATE" />
				</div>
				<br/>
				<div align="left">
					<xsl:apply-templates select="TO" />
				</div>
				<br/>
				<div align="right">
					<xsl:value-of select="AUTHOR/AFF" /><br/>
				</div>
			</font>

			<br/><br/>
			<div align="center">
				<table width="400">
					<tr><td>
						<u><center><xsl:value-of select="TITLE" /></center></u>
					</td></tr>
				</table>
			</div>

			<xsl:apply-templates select="MAINTXT" />

			<xsl:apply-templates select="MAINTXT2" />

			<xsl:apply-templates select="REFERENC" />

			<br/><br/>
		</body>

	</html>
	</xsl:template>

	<xsl:template match="DATE">
		<xsl:choose>
			<xsl:when test="./@TYPE=5" >令和</xsl:when>
			<xsl:when test="./@TYPE=4" >平成</xsl:when>
			<xsl:when test="./@TYPE=3" >昭和</xsl:when>
			<xsl:when test="./@TYPE=2" >大正</xsl:when>
			<xsl:when test="./@TYPE=1" >明治</xsl:when>
		</xsl:choose>
		<xsl:value-of select="substring(.,1,2)" />年
		<xsl:value-of select="substring(.,3,2)" />月
		<xsl:value-of select="substring(.,5)" />日<br/>
	</xsl:template>

	<xsl:template match="TO">
		<xsl:value-of select="AFF" />　
		<xsl:value-of select="NAME" />　
		<xsl:value-of select="HONORIFC" /><br/>
	</xsl:template>

	<xsl:template match="MAINTXT">
		<br/><br/>
		<xsl:for-each select="P">
			<xsl:value-of select="." /><br/>
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="MAINTXT2">
		<br/><br/>
		<div align="center">
			<xsl:value-of select="MT2TITLE" /><br/>
		</div>
		<br/>
		<xsl:for-each select="MT2TEXT/P">
			<xsl:value-of select="." /><br/>
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="REFERENC">
		<br/><br/>
		<xsl:for-each select="P">
			<font size="-1">
				<xsl:value-of select="." /><br/>
			</font>
		</xsl:for-each>
	</xsl:template>

</xsl:stylesheet>
