<?xml-stylesheet href="http://www.w3.org/StyleSheets/base.css" type="text/css"?><?xml-stylesheet href="http://www.w3.org/2002/02/style-xsl.css" type="text/css"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" exclude-result-prefixes="tt ttm html" xmlns:tt="http://www.w3.org/2006/10/ttaf1" xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata">

<!-- Output method XML -->
<xsl:output method="xml" 
  indent="yes"
  omit-xml-declaration="no" 
  encoding="utf-8" 
  doctype-system="http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"
  doctype-public="-//W3C//DTD XHTML+RDFa 1.0//EN"  />

<xsl:param name="videoUrl" />
<xsl:param name="videoType" />
<xsl:param name="dfxpUrl" />
<xsl:param name="topicSlides" />
<xsl:param name="topicNotes" />

<xsl:template match="/tt:tt">
  <html  xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  xmlns:dc="http://purl.org/dc/elements/1.1/">
    <xsl:apply-templates select="@xml:lang"/>
    <head>
      <title><xsl:value-of select="tt:head/tt:metadata/ttm:title"/></title>
      <link rel="stylesheet" href="/2009/02/presentation-viewer/style.css" />
      <link rel="stylesheet" href="/StyleSheets/public" />
    </head>
    <body>
      <h1><xsl:value-of select="tt:head/tt:metadata/ttm:title"/></h1>
      <div class="video">
        <h2 xml:lang="en">Video</h2>
      <video  controls="controls"  id="video" width="640" height="400">
        <source src="{$videoUrl}" type="{$videoType}" />
        <source src="{$dfxpUrl}" type="application/ttaf+xml" title="Subtitles"/>
      </video>
      </div>
      <div class="slides">
      <xsl:if test="$topicSlides">
        <h2 xml:lang="en">Slides</h2>
        <object id="slides"  name="slides" data="{document($topicSlides)/ul/li/a[1]/@href}" width="640" height="600">&#xA0;</object>
      </xsl:if>
      </div>
      <div class="toc">
      <h2 xml:lang="en">Table of Contents</h2>
      <ul class="toc">
        <xsl:for-each select=".//tt:div[@ttm:title]">
          <xsl:variable name="videoFragment" select="concat($videoUrl,'#t=',.//tt:p[1]/@begin,',',.//tt:p[last()]/@end)"/>
          <li about="{$videoFragment}">
            <a target='slides' property="dc:title">
              <xsl:if test="$topicSlides and document($topicSlides)/ul">
                <xsl:attribute name="rel">foaf:depiction</xsl:attribute>
              </xsl:if>
              <xsl:attribute name="href">
                <xsl:choose>
                  <xsl:when test="$topicSlides and document($topicSlides)/ul">
                    <xsl:value-of select="document($topicSlides)/ul/li/a[.=current()/@ttm:title]/@href"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="$videoFragment"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:attribute>
              <xsl:value-of select="@ttm:title"/>
            </a>
          </li>
        </xsl:for-each>
      </ul>
      </div>
      <div class="notes">
        <xsl:if test="$topicNotes and document($topicNotes)">
          <h2>Notes</h2>
        <object id="notes" width="640" height="400" data="{document($topicNotes)/ul/li[1]/a/@href}">
      <ul class="toc">
        <xsl:for-each select=".//tt:div[@ttm:title]">
          <xsl:variable name="videoFragment" select="concat($videoUrl,'#t=',.//tt:p[1]/@begin,',',.//tt:p[last()]/@end)"/>
          <li about="{$videoFragment}">
            <a target='notes'>
              <xsl:if test="$topicNotes and document($topicNotes)/ul">
                <xsl:attribute name="rel">rdf:seeAlso</xsl:attribute>
              </xsl:if>
              <xsl:attribute name="href">
                <xsl:choose>
                  <xsl:when test="$topicNotes and document($topicNotes)/ul">
                    <xsl:value-of select="document($topicNotes)/ul/li/a[.=current()/@ttm:title]/@href"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="$videoFragment"/>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:attribute>
              <xsl:value-of select="@ttm:title"/>
            </a>
          </li>
        </xsl:for-each>
      </ul>

        </object>
        </xsl:if>
      </div>
      <script src="/2008/site/js/jquery.js" type="text/javascript">&#xA0;</script>
      <script src="/2009/02/presentation-viewer/HTML5_player.js" type="text/javascript">&#xA0;</script>
      <script type="text/javascript" src="/2009/02/presentation-viewer/sync.js">&#xA0;</script>
    </body>
  </html>
</xsl:template>

  <!-- default: Identity Transformation -->
  <xsl:template match="*|@*|comment()|text()">
    <xsl:copy>
      <xsl:apply-templates select="*|@*|comment()|text()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>