<?xml version="1.0" encoding="EUC-JP"?>
<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:p="http://www.horobi.com/xmlns/program"
>
<xsl:output method="html" encoding="EUC-JP"/>
<xsl:template match="/">
  <html>
    <head><title>
     <xsl:value-of select="/p:program/p:title"/>
     [<xsl:value-of select="/p:program/p:date"/>]</title>
    </head>
    <body>
      <xsl:apply-templates/>
    </body>
  </html>
</xsl:template>

<xsl:template match="p:program">
  <table width="100%">
    <tr>
      <th colspan="2" bgcolor="#ffcccc">
        <xsl:value-of select="p:title"/>
        <div align="right">
          放送日:<xsl:value-of select="p:date"/><br/>
	  筆記:<xsl:value-of select="p:transcript"/>
        </div>
      </th>
    </tr>
    <xsl:apply-templates select="p:guest"/>
    <xsl:apply-templates select="p:corner"/>
  </table>
</xsl:template>

<xsl:template match="p:guest"> 
    <tr>
      <th>今週のゲスト:</th>
      <td><xsl:value-of select="."/></td>
    </tr>
</xsl:template>

<xsl:template match="p:corner">
    <tr>
      <th colspan="2" bgcolor="#ffffcc">
        <xsl:value-of select="p:subject"/>
      </th>
    </tr>
    <tr><th width="20%"></th><td></td></tr>

    <xsl:choose>
      <xsl:when test="p:corner2">
        <xsl:apply-templates select="p:corner2"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="p:speaker|p:omission|p:direction|p:note"/>
      </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template match="p:corner2">
  <tr>
    <th colspan="2" align="left" bgcolor="#cccccc">
      <xsl:value-of select="p:subject"/>
    </th>
  </tr>
  <xsl:apply-templates select="p:speaker|p:omission|p:direction|p:note"/>
</xsl:template>

<xsl:template match="p:speaker">
  <tr valign="top">
    <th align="right">
      <font color="#0055cc"><xsl:value-of select="."/></font>
      <xsl:text> :</xsl:text>
    </th>
    <td><xsl:apply-templates select="following-sibling::p:words[1]"/></td>
  </tr>
</xsl:template>

<xsl:template match="p:br">
  <br/><br/>
</xsl:template>

<xsl:template match="p:a">
  <a href="@href"><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="p:note">
  <td colspan="2">
    <font size="2" color="gray">※ <xsl:apply-templates/></font>
  </td>
</xsl:template>

<xsl:template match="p:omission">
  <tr>
    <td colspan="2" align="center">
      <font color="#555555">(略)</font>
    </td>
  </tr>
</xsl:template>

<xsl:template match="p:direction">
  <tr>
    <td colspan="2">
      <font color="#555555">…<xsl:value-of select="."/>…</font>
    </td>
  </tr>
</xsl:template>

</xsl:stylesheet>