<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                version="1.0">
  
  <!-- =============================================================== -->
  <!--  disputas-edit.xsd (v001)                                       -->
  <!--  19.10.06 - kristian.syversen@usit.uio.no                       -->
  <!-- =============================================================== -->
  
  <!-- =============================================================== -->
  <!--  Dokumenttypens hovedelement blir matchet i system-edit.xsl.    -->
  <!-- =============================================================== -->
  
  <xsl:import href="../../../system/system-edit-v001.xsl"/>
  <xsl:import href="../../../system/api-edit-v001.xsl"/>
  <xsl:import href="../../../system/formelements-edit-v001.xsl"/>
  
  <xsl:import href="../../../felles/ressurser/url-tools-v001.xsl" />
  
  <xsl:import href="../../../felles/komponenter/fritekst/v002/fritekst-edit.xsl"/>
  <xsl:import href="../../../felles/komponenter/tid-og-sted/v001/tid-og-sted-edit.xsl" />
  
  <!-- =============================================================== -->
  <!--  Templates som kalles i system-edit.xsl kan overstyres her.     -->
  <!--  Se avsnitt "Template name API" i system-edit.xsl for oversikt  -->
  <!--  over disse.                                                    -->
  <!-- =============================================================== -->
  
  <!-- Definer det statiske elementet rett før de flyttbare elementene -->
  <xsl:variable name="movable-or-deletable-elements-after" select="''" />
  
  <!-- DTD-syntaks for flyttbare og slettbare elementer (men ikke bruk mellomrom)-->
  <xsl:variable name="movable-or-deletable-elements" select="''" />
  
  <!-- css-klasser kan som brukes i denne dok. typen kan legges inn her -->
  <xsl:template name="css-classes" />
  
  <!-- shortcuts for å sette inn elementer nederst spesifiseres i denne -->
  <xsl:template name="shortcutlinks-put-bottom" />
  
  
  <xsl:template name="choice-subelements">
      <xsl:choose>
        <xsl:when test="name()='referanser'">
          <xsl:value-of select="'referanse'"/>
        </xsl:when>
        <xsl:when test="name()='medlemmer'">
          <xsl:value-of select="'medlem'"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="''"/> 
        </xsl:otherwise>
      </xsl:choose>
  </xsl:template>
  
  
  <xsl:template match="doktorand">
    <b>Doktorand:</b>&#160;<xsl:if test="tittel!=''"><xsl:value-of select="tittel"/><xsl:text> </xsl:text></xsl:if><xsl:value-of select="fornavn"/><xsl:text> </xsl:text><xsl:value-of select="etternavn"/>&#160;<xsl:call-template name="insert-edit-link" /> 
  </xsl:template>

  <xsl:template match="doktorand" mode="edit">
    <xsl:call-template name="sequence-edit" />
  </xsl:template>
  
  <xsl:template match="doktorand/tittel" mode="edit">
    <xsl:call-template name="insert-inputfield"/>
  </xsl:template>
  
  <xsl:template match="doktorand/fornavn" mode="edit">
    <xsl:call-template name="insert-inputfield"/> (Skriv ogs&#229; mellomnavn i dette feltet)
  </xsl:template>

  <xsl:template match="doktorand/etternavn" mode="edit">
    <xsl:call-template name="insert-inputfield"/>
  </xsl:template>
  
  
  <xsl:template match="tilhorighet">
    <b>Tilh&#248;righet:</b>&#160;<xsl:value-of select="." />&#160;<xsl:call-template name="insert-edit-link" />
  </xsl:template>
  
  
  <xsl:template match="oppgavetittel">
    <b>Oppgavetittel:</b>&#160;<xsl:value-of select="." />&#160;<xsl:call-template name="insert-edit-link" />
  </xsl:template>
  
  <xsl:template match="oppgavetittel" mode="edit">
    <xsl:call-template name="insert-textarea">
      <xsl:with-param name="cols" select="'80'" />
      <xsl:with-param name="rows" select="'2'" />
      <xsl:with-param name="helptext" select="'no'" />
    </xsl:call-template>
  </xsl:template>
  
  
  <xsl:template match="grad">
    <b>Grad:</b>&#160;<xsl:value-of select="." />&#160;<xsl:call-template name="insert-edit-link" />
  </xsl:template>
  
  <xsl:template match="grad" mode="edit">
    <xsl:variable name="grad-liste">
      ph.d. (philosophiae doctor)=ph.d. (philosophiae doctor),
      dr.art. (doctor artium)=dr.art. (doctor artium), 
      dr.juris. (doctor juris)=dr.juris. (doctor juris),
      dr.med. (doctor medicinae)=dr.med. (doctor medicinae),
      dr.odont. (doctor odontologiae)=dr.odont. (doctor odontologiae),
      dr.philos. (doctor philosophiae)=dr.philos. (doctor philosophiae),
      dr.polit. (doctor rerum politicarum)=dr.polit. (doctor rerum politicarum),
      dr.psychol. (doctor psychologiae)=dr.psychol. (doctor psychologiae),
      dr.scient. (doctor scientiarum)=dr.scient. (doctor scientiarum),
      dr.theol. (doctor theologiae)=dr.theol. (doctor theologiae)
    </xsl:variable>
    <xsl:call-template name="insert-dropdown">
      <xsl:with-param name="name-value-list" select="normalize-space($grad-liste)" />
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="proveforelesninger">
    <b>Pr&#248;veforelesninger:</b>&#160;<xsl:call-template name="insert-edit-link" />
    <br /> 
    <xsl:apply-templates />    
  </xsl:template> 
    
  <xsl:template match="proveforelesninger | komite" mode="edit">
    <xsl:call-template name="sequence-edit" />
  </xsl:template> 
  
  
  <xsl:template match="referanser">
    <xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="referanser | medlemmer" mode="edit">
    <xsl:call-template name="choice-edit" />
  </xsl:template> 
  
  
  <xsl:template match="referanse">
    <xsl:if test=".!=''">
      <p>
        <xsl:variable name="url">
          <xsl:call-template name="make-me-a-url-xml">
            <xsl:with-param name="ref" select="." />
          </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="doc" select="document($url, self::node())" />        
        <xsl:choose>
          <xsl:when test="not($url='false') and $doc/node()">
            <xsl:variable name="root" select="$doc/proveforelesning" />
            <xsl:choose>
              <xsl:when test="$root/node()">
                <a href="{$url}"><xsl:apply-templates select="$root/tid-og-sted/start"/> - <xsl:value-of select="$root/emne"/></a>
              </xsl:when>
              <xsl:otherwise>
                <a href="{$url}"> <xsl:value-of select="."/> </a> &#160; <span style="color:red">XML-dokumentet er ikke av type pr&#248;veforelesning</span>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise>
            <a href="{$url}"> <xsl:value-of select="."/> </a> &#160; <span style="color:red">Referansen peker ikke til et gyldig XML-dokument (eller dokumentet ble ikke funnet)</span>
          </xsl:otherwise>
        </xsl:choose>
      </p>
    </xsl:if>
  </xsl:template>
  
  <xsl:template match="referanse" mode="edit"> 
    <xsl:call-template name="insert-inputfield">
      <xsl:with-param name="size" select="60" />
    </xsl:call-template>&#160;<xsl:call-template name="insert-browsebutton" />
  </xsl:template>
  
  <xsl:template match="kommentar">
    <xsl:apply-templates />
  </xsl:template> 
  
  <xsl:template match="kommentar" mode="edit">
    <xsl:call-template name="insert-textarea" />
  </xsl:template> 
  
  
  <xsl:template match="komite">
    <b>Bed&#248;mmelseskomit&#233;:</b>&#160;<xsl:call-template name="insert-edit-link" />
    <br /> 
    <xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="medlemmer">
    <xsl:apply-templates/>
  </xsl:template>
  
  <xsl:template match="medlem">
    <xsl:value-of select="." /> <br />
  </xsl:template>
  
  <xsl:template match="medlem" mode="edit">
    <xsl:call-template name="insert-inputfield">
      <xsl:with-param name="size" select="'50'" />
    </xsl:call-template>
  </xsl:template>
  
  <xsl:template match="leder-av-disputas">
    <b>Leder av disputas:</b> &#160; <xsl:value-of select="." /> &#160; <xsl:call-template name="insert-edit-link" />
  </xsl:template>
  
  <xsl:template match="leder-av-disputas" mode="edit">
    <xsl:call-template name="insert-inputfield">
      <xsl:with-param name="size" select="'50'" />
    </xsl:call-template>
  </xsl:template>
  
  
  <xsl:template match="veileder">
    <b>Veileder:</b> &#160; <xsl:value-of select="." /> &#160; <xsl:call-template name="insert-edit-link" />
  </xsl:template>
  
  <xsl:template match="veileder" mode="edit">
    <xsl:call-template name="insert-inputfield">
      <xsl:with-param name="size" select="'50'" />
    </xsl:call-template>
  </xsl:template>
  
  
  <xsl:template match="sammendrag">
    <b>Sammendrag:</b>&#160;<xsl:call-template name="insert-edit-link" />
    <br /> 
    <xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="sammendrag" mode="edit">
    <xsl:call-template name="insert-textarea" />
  </xsl:template>
  
  
  <xsl:template match="kontaktperson">
    <b>Kontaktperson:</b>&#160;<xsl:call-template name="insert-edit-link" />
    <br />Navn:&#160;<xsl:value-of select="navn"/>
    <br />Brukernavn:&#160;<a href="{concat('http://www.uio.no/sok?person=', brukernavn)}" target="nyvin"><xsl:value-of select="brukernavn"/></a>
  </xsl:template>
  
  <xsl:template match="kontaktperson" mode="edit">
    <xsl:call-template name="sequence-edit" />   
  </xsl:template>
  
  
  <xsl:template match="tilhorighet | sted | navn | brukernavn" mode="edit">
    <xsl:call-template name="insert-inputfield" />
  </xsl:template>

</xsl:stylesheet>
