<?xml version='1.0'?>

<xsl:stylesheet xmlns:xsl='http://www.w3.org/TR/WD-xsl'
                xmlns="http://www.w3.org/TR/REC-html40">

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

  <xsl:template match="text()"><xsl:value-of select='.'/></xsl:template>

  <xsl:template match="/">
    <html><head>
<!-- NOTE: The form of this HTML is subject to change.  Do not parse the
     HTML; parse the XML instead. -->
    <link rel='stylesheet' href='/global.css' type='text/css'></link>
    </head><body>
      <xsl:apply-templates/>
    </body></html>
  </xsl:template>
  
  <xsl:template match="gnd">
    <CENTER><H2>
      Ground Truth for <I>"<xsl:value-of select="@file-id"/>"</I>
    </H2></CENTER>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match='annotation'>
    <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match='annotation[@title]'>
    <h3><xsl:value-of select='@title'/></h3>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match='sets'/>
  <xsl:template match='sets[set[@name]]'><ul><xsl:apply-templates/></ul></xsl:template>

  <xsl:template match='sets/set'/>
  <xsl:template match='sets/set[@name]'>
    <li>Part of set <i>"<xsl:value-of select='@name'/>"</i></li>
  </xsl:template>

  <xsl:template match="gnd/raw-data">
    <H3>Data:</H3>
    <UL><xsl:apply-templates/></UL>
  </xsl:template>

  <xsl:template match='data'>
    <LI><b>Raw Data: 
      <xsl:if test='@link'>
        <A><xsl:attribute name='href'><xsl:value-of select='@link'/></xsl:attribute>
<!-- NOTE: The next line is used for a server side script to find the image
        <A><xsl:attribute name='href'>fetch.pl?there=<xsl:value-of select='@link'/></xsl:attribute>
-->
          <xsl:value-of select='@link'/></A>
        <xsl:if test='@file-format'>(<i>"<xsl:value-of select="@file-format"/>"</i> format)</xsl:if>
      </xsl:if>
    </b></LI>
  </xsl:template>

  <xsl:template match='parent/data'/>

  <xsl:template match='capture'>
    <H3>Capture Information:</H3>
    <UL><xsl:apply-templates/></UL>
  </xsl:template>

  <xsl:template match='capture/organization'>
    <li>Organization: <i>"<xsl:value-of select='@name'/>"</i></li>
  </xsl:template>

  <xsl:template match='motion'><xsl:apply-templates/></xsl:template>

  <xsl:template match='motion/direction'>
    <li>Motion- direction: 
      <xsl:if test='@name'>name=<i>"<xsl:value-of select='@name'/>"</i></xsl:if>
    </li>
  </xsl:template>

  <xsl:template match='range'>
    <li>Range to subject: 
      <xsl:if test='@name'>name=<i><xsl:value-of select='@name'/></i></xsl:if>
      <xsl:if test='@distance'>name=<i><xsl:value-of select='@distance'/></i></xsl:if>
      <xsl:if test='@units'>name=<i><xsl:value-of select='@units'/></i></xsl:if>
    </li>
  </xsl:template>

  <xsl:template match='derivation'>
    <H3>Derivation</H3>
    <ol><xsl:apply-templates/></ol>
  </xsl:template>

  <xsl:template match='renamed'/>
  <xsl:template match='renamed[@from]'>
    <li>Renamed from: <i>"<xsl:value-of select='@from'/>"</i></li>
  </xsl:template>

  <xsl:template match='parents'>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match='parent'>
    <LI>
      <B>Parent: </B>
      <xsl:if test='@truth'>ground truth=
<!-- NOTE: The next line is used for a server side script to find the image
        <A><xsl:attribute name='href'>fetch.pl?there=<xsl:value-of select='@truth'/></xsl:attribute>
-->
        <A><xsl:attribute name="href"><xsl:value-of select='@truth'/></xsl:attribute>
          <xsl:value-of select='@truth'/></A>
      </xsl:if>
      <xsl:if test='data/@data'>raw data=
<!-- NOTE: The next line is used for a server side script to find the image
        <A><xsl:attribute name='href'>fetch.pl?there=<xsl:value-of select='@truth'/></xsl:attribute>
-->
        <A><xsl:attribute name="href"><xsl:value-of select='data/@data'/></xsl:attribute>
          <xsl:value-of select='data/@data'/></A>
        <xsl:if test='data/@file-format'>(<I>
          <xsl:value-of select='data/@file-format'/>
        )</I></xsl:if>
      </xsl:if>
    </LI>
  </xsl:template>

  <xsl:template match='time'>
    <LI>Date: 
      <I>
        <xsl:if test='@month'><xsl:value-of select="@month"/> </xsl:if>
        <xsl:if test='@day'>
          <xsl:value-of select="@day"/>, 
        </xsl:if>
        <xsl:if test='@year'>
          <xsl:value-of select="@year"/>
        </xsl:if>
      </I>
    </LI>
  </xsl:template>

  <xsl:template match="time[@hour | @min | @sec]">
    <LI>Date:  
      (<I><xsl:if test='@hour'><xsl:value-of select='@hour'/></xsl:if>:<xsl:if test='@min'><xsl:value-of select='@min'/></xsl:if><xsl:if test='@sec'>:<xsl:value-of select='@sec'/></xsl:if></I>)
      <I>
        <xsl:if test='@month'><xsl:value-of select="@month"/> </xsl:if>
        <xsl:if test='@day'>
          <xsl:value-of select="@day"/>, 
        </xsl:if>
        <xsl:if test='@year'>
          <xsl:value-of select="@year"/>
        </xsl:if>
      </I>
    </LI>
  </xsl:template>

  <xsl:template match='site'>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match='site[@name]'>
    <li>Capture site- name: <i>"<xsl:value-of select='@name'/>"</i></li>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match='subjects'>
    <H3>Subjects:</H3>
    <UL>
      <xsl:apply-templates/>
    </UL>
  </xsl:template>

  <xsl:template match='subjects/subject'>
    <LI><B>Subject (unknown ID number)</B>
      <xsl:apply-templates/>
    </LI>
  </xsl:template>

  <xsl:template match='subjects/subject[@subject-id]'>
    <LI><B>
      Subject id =
      <I><xsl:value-of select='@subject-id'/></I>
    </B></LI>
    <xsl:apply-templates/>
  </xsl:template>


  <!-- Sensor-related stuff -->

  <xsl:template match='user'/>
  <xsl:template match='sensor-name'/>

  <xsl:template match='sensor'>
    <xsl:if test='@name'>
      <LI>
        Sensor name: <I>"<xsl:value-of select='@name'/>"</I>
      </LI>
    </xsl:if>
    <xsl:if test='operator[@name]'>
      <LI>
        Sensor operator: <I>"<xsl:value-of select='operator/@name'/>"</I>
      </LI>
    </xsl:if>
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match='sensor/details/sensor-media'/>
  <xsl:template match='sensor/details/sensor-media[@name]'>
    <LI>
      Sensor media:
      <i>"<xsl:value-of select='@name'/>"</i>
    </LI>
  </xsl:template>
  
  <xsl:template match='sensor/details'>
    <LI>
      Sensor details:
      <UL><xsl:apply-templates/></UL>
    </LI>
  </xsl:template>




  <!-- Face-related stuff -->


  <xsl:template match='face'>
    <LI>
      Subject's face:
      <UL>
        <xsl:apply-templates/>
      </UL>
    </LI>
  </xsl:template>

  <xsl:template match='pose'/>

  <xsl:template match="face/pose[@angle | @name]">
    <LI>
      Pose: 
      <xsl:if test='@angle'> angle=<I><xsl:value-of select='@angle'/></I></xsl:if>
      <xsl:if test='@name'> name=<i><xsl:value-of select='@name'/></i></xsl:if>
    </LI>
  </xsl:template>

  <xsl:template match='expression'/>

  <xsl:template match='face/expression[@name]'>
    <LI>
      Expression: <I><xsl:value-of select='@name'/></I>
    </LI>
  </xsl:template>

  <xsl:template match='FERET'/>

  <xsl:template match='FERET[@pose | @special-flag]'>
    <LI>FERET: 
      <xsl:if test='@pose'>
        pose=<I><xsl:value-of select='@pose'/></I>
      </xsl:if>
      <xsl:if test='@special-flag'>
        special flag=<I><xsl:value-of select='@special-flag'/></I>
      </xsl:if>
    </LI>
  </xsl:template>

  <xsl:template match='sex'/>

  <xsl:template match='sex[@presumed | @retrospectively | @given]'>
    <LI>Sex: 
      <xsl:if test='@presumed'>
        presumed=<I><xsl:value-of select='@presumed'/></I>
      </xsl:if>
      <xsl:if test='@retrospectively'>
        retrospective=<I><xsl:value-of select='@retrospectively'/></I>
      </xsl:if>
      <xsl:if test='@given'>
        given=<I><xsl:value-of select='@given'/></I>
      </xsl:if>
    </LI>
  </xsl:template>

  <xsl:template match='left-eye'>
    <LI>
      Left Eye: x=<I><xsl:value-of select='@x'/></I>, y=<I><xsl:value-of select='@y'/></I>
    </LI>
  </xsl:template>

  <xsl:template match='right-eye'>
    <LI>
      Right Eye: x=<I><xsl:value-of select='@x'/></I>, y=<I><xsl:value-of select='@y'/></I>
    </LI>
  </xsl:template>

  <xsl:template match='wearing'/>

  <xsl:template match='wearing[@glasses]'>
    <LI>Subject was wearing:
      <xsl:if test='@glasses'>
        glasses=<I><xsl:value-of select='@glasses'/></I>
      </xsl:if>
    </LI>
  </xsl:template>

  <xsl:template match='nose'>
    <LI>
      Nose Tip: x=<I><xsl:value-of select='@x'/></I>, y=<I><xsl:value-of select='@y'/></I>
    </LI>
  </xsl:template>

  <xsl:template match='mouth'>
    <LI>
      Mouth Center: x=<I><xsl:value-of select='@x'/></I>, y=<I><xsl:value-of select='@y'/></I>
    </LI>
  </xsl:template>




  <!-- Image-processing-related stuff -->

  <xsl:template match='processing'/>

  <xsl:template match='processing[@compression-ratio | @command | @resize | @bright-reduction]'>
    <LI>Image Processing: <ul>
      <xsl:if test='@resize'>
        <li>Resize: <I><xsl:value-of select='@resize'/></I></li>
      </xsl:if>
      <xsl:if test='@compression-ratio'>
        <li>Compression ratio: <I><xsl:value-of select='@compression-ratio'/></I></li>
      </xsl:if>
      <xsl:if test='@bright-reduction'>
        <li>Bright reduction: <i><xsl:value-of select='@bright-reduction'/></i></li>
      </xsl:if>
      <xsl:if test='@command'>
        <li>Command: "<CODE><xsl:value-of select='@command'/></CODE>"</li>
      </xsl:if>
      <xsl:apply-templates/>
    </ul></LI>
  </xsl:template>  

  <xsl:template match='intended-eye-separation'>
    <li>Intended eye separation: 
      <xsl:if test='@distance'> distance=<i><xsl:value-of select='@distance'/></i></xsl:if>
      <xsl:if test='@units'> units=<i><xsl:value-of select='@units'/></i></xsl:if>
    </li>
  </xsl:template>

  <xsl:template match="illumination"/>

  <xsl:template match='illumination[@type]'>
    <LI>Illumination:
    <I>"<xsl:value-of select='@type'/>"</I></LI>
  </xsl:template>

  <xsl:template match='frame-range'>
    <LI>
      Sample Frame Range: 
      <xsl:if test='@begin'>
        begin=<I><xsl:value-of select='@begin'/></I>
      </xsl:if>
      <xsl:if test='@end'>
        end=<I><xsl:value-of select='@end'/></I>
      </xsl:if>
      <xsl:if test='@units'>
        units=<I><xsl:value-of select='@units'/></I>
      </xsl:if>
      <xsl:if test='@stream'>
        stream=<I><xsl:value-of select='@stream'/></I>
      </xsl:if>
    </LI>
  </xsl:template>

</xsl:stylesheet>
