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

  <!-- ========================================================================== -->
  <!-- tid-og-sted.xsl (versjon 001)                                              -->
  <!-- ========================================================================== -->

  <!-- Felles for studiedokumenter -->

  <xsl:include href="http://www.uio.no/vrtx/vortex-webdocuments/studier/ressurser/profil-v001.xsl"/>
  <xsl:include href="http://www.uio.no/vrtx/vortex-webdocuments/studier/ressurser/translations-v001.xsl"/>
  <xsl:include href="http://www.uio.no/vrtx/vortex-webdocuments/studier/ressurser/mapping-v001.xsl"/>
  <!--
  <xsl:include href="../../ressurser/profil-v001.xsl"/>
  <xsl:include href="../../ressurser/translations-v001.xsl"/>
  <xsl:include href="../../ressurser/mapping-v001.xsl"/>
-->

  <!-- Felles for alle dokumenter -->
  <xsl:include href="http://www.uio.no/vrtx/vortex-webdocuments/system/api-v001.xsl"/>
  <xsl:include href="http://www.uio.no/vrtx/vortex-webdocuments/felles/ressurser/output-method-html-v001.xsl"/>
  <!--
  <xsl:include href="../../../system/api-v001.xsl"/>
  <xsl:include href="../../../felles/ressurser/output-method-html-v001.xsl"/>
-->
  <xsl:template match="/">
    <html>
      <head>
        <title>
          <xsl:text>TUT -- TUT -- TUT!!  </xsl:text>
          <xsl:call-template name="oversett-diverse">
          <xsl:with-param name="diversetekst" select="'Undervisning - tid og sted'" />
          </xsl:call-template> 
          (<xsl:value-of select="//emnekode"/> - 
          <xsl:value-of select="//semester" />&#160;<xsl:value-of select="//aar"/>)
        </title>
        <!-- Henter metadata fra profil-v001.xsl -->
        <xsl:call-template name="inkluder-metadata-til-profil"/>
      </head>

      <body>
        <xsl:call-template name="studiesti"/>
        <h1 id="tekststart">
          <xsl:text>TUT -- TUT -- TUT!!  </xsl:text>
          <xsl:call-template name="oversett-diverse">
          <xsl:with-param name="diversetekst" select="'Undervisning - tid og sted'" />
          </xsl:call-template> 
          (<xsl:value-of select="/tid-og-sted/emnekode"/> - 
          <xsl:value-of select="/tid-og-sted/semester"/>&#160;<xsl:value-of select="/tid-og-sted/aar"/>)
        </h1>
        <!-- font size="+1" color="red">Bygningsangivelse vil kunne mangle på enkelte emner. Denne informasjonen kommer om kort tid.</font-->
        <!-- font size="+1" color="red">OBS: Dette dokumentet inneholder feil informasjon! Korrekt informasjon kommer mellom 14-18 juli.</font -->
        <xsl:apply-templates/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="emnekode | semester | aar" /> <!-- skrives ut i tittel -->

  <xsl:template match="undervisning"> <!-- avsnitt?, person+, oppmeldingsfrist?, paameldingstype?, undervisningsaktivitet+ -->
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="person">
    <xsl:value-of select="." />
    <xsl:if test="not(position()=last())">
      <xsl:text>, </xsl:text>	
    </xsl:if>
  </xsl:template>

  <xsl:template match="oppmeldingsfrist">
    <xsl:apply-templates /> <!-- kan inneholde dato -->
  </xsl:template>

  <xsl:template match="paameldingstype">
    <xsl:value-of select="@type" /> <!-- skriver ut attributtverdi, hvis satt, behov for fellestekst? --> 
   <xsl:apply-templates /> <!-- kan inneholde dato ?? -->
  </xsl:template>
 
  <xsl:template match="undervisningsaktivitet">
    <xsl:choose>
      <xsl:when test="@nivaa='n1'">
        <h2><xsl:apply-templates select="overskrift" /></h2>
      </xsl:when>
      <xsl:when test="@nivaa='n2'">
        <h3><xsl:apply-templates select="overskrift" /></h3>
      </xsl:when>
      <xsl:when test="@nivaa='n3'">
        <h4><xsl:apply-templates select="overskrift" /></h4>
      </xsl:when>
    </xsl:choose>
  
    <xsl:apply-templates select="undervisningsparti-id" />
    <xsl:apply-templates select="avsnitt"/>

    <xsl:if test="timeplanelement!=''">
      <ul>
        <xsl:apply-templates select="timeplanelement"/>
      </ul>
    </xsl:if>

    <xsl:if test="not(normalize-space(person)='')"><p><xsl:apply-templates select="person" /></p></xsl:if> 
    <xsl:if test="not(normalize-space(forste-gang)='')"><xsl:apply-templates select="forste-gang" /><br/></xsl:if> 
    <xsl:if test="not(normalize-space(siste-gang)='')"><xsl:apply-templates select="siste-gang" /><br/></xsl:if> 
    <xsl:if test="not(normalize-space(varighet)='')"><xsl:apply-templates select="varighet" /><br/></xsl:if> 
  </xsl:template>


  <xsl:template match="undervisningsparti-id">
    <!-- p>Undervisningsparti-id:  <xsl:value-of select="." /></p --> 
  </xsl:template>

  <xsl:template match="forste-gang">
    <xsl:call-template name="oversett-element"/><xsl:value-of select="." /> 
  </xsl:template>

  <xsl:template match="siste-gang">
    <xsl:call-template name="oversett-element"/><xsl:value-of select="." /> 
  </xsl:template>

  <xsl:template match="varighet">
    <xsl:call-template name="oversett-element"/><xsl:value-of select="." /> 
  </xsl:template>

  <xsl:template match="timeplanelement">
    <li>
    <xsl:apply-templates select="ukedag" />
    <xsl:apply-templates select="dato" />
    <xsl:apply-templates select="klokkeslett-fra" />
    <xsl:apply-templates select="klokkeslett-til" />
    <xsl:apply-templates select="undervisningssted" />
    <xsl:apply-templates select="tidsperiode" />

    <xsl:if test="not(normalize-space(person)='')">, <xsl:apply-templates select="person" /></xsl:if> 
      <xsl:if test="not(normalize-space(avsnitt)='')">
	<xsl:for-each select="avsnitt">
	  <br/><xsl:value-of select="." />
	</xsl:for-each>
      </xsl:if> 
    </li>
  </xsl:template>

  <xsl:template match="ukedag"><xsl:value-of select="." /></xsl:template>

  <xsl:template match="dato">&#160;<xsl:value-of select="." /></xsl:template>

  <xsl:template match="klokkeslett-fra">
    <xsl:text> </xsl:text> <xsl:if test="$malspraak!='engelsk'">kl. </xsl:if>
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="klokkeslett-til">
    -<xsl:value-of select="." /> 
  </xsl:template>

  <xsl:template match="tidsperiode">
    ( <xsl:if test="$malspraak!='engelsk'">i perioden </xsl:if><xsl:value-of select="dato-fra"/>
    <xsl:choose>
      <xsl:when test="$malspraak='engelsk'"> to </xsl:when>
      <xsl:otherwise> til </xsl:otherwise>
    </xsl:choose>
    <xsl:value-of select="dato-til"/>)
  </xsl:template>

  <xsl:template match="undervisningssted">,&#160;<xsl:apply-templates select="rom" />&#160;<xsl:apply-templates select="bygning" />
  </xsl:template>

  <xsl:template match="rom">
     <xsl:value-of select="." /> 
  </xsl:template>

  <xsl:template match="bygning">
     <xsl:value-of select="." /> 
  </xsl:template>

  <xsl:template match="eksamen">
    <h3><xsl:call-template name="oversett-element" /></h3>
    <xsl:apply-templates />
  </xsl:template>



  <!-- grunnelementer som overstyrer common-view.xsl -->

  <xsl:template match="overskrift">
    <xsl:value-of select="." />
  </xsl:template>

  <xsl:template match="avsnitt">
    <p><xsl:apply-templates/></p>
  </xsl:template>

  <xsl:template match="weblenke">
    <a href="{webadresse}"><xsl:value-of select="lenketekst"/></a>
  </xsl:template>

</xsl:stylesheet>
