<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Style sheet that builds a nice printable paper a SRF file!

@author <a href="mailto:david@purple-sunshine.de">david (holger) wagner</a>
@version $Revision: 1.12 $ $Date: 2002/12/08 19:03:17 $
         - created before 2002-02-09

See end of file for a changelog.

NOTES:
- Sometimes, whitespace is omitted, which is not good for legibility
  of this XSLT-File. However, it improves readibility of the final
  XHTML file, which is obviously more important...
- The difference between printing and viewing on screen is realized
  with CSS. Therefore, the same resulting XHTML file can be used
  for both. See "noprint" and "printonly" classes.
- Headlines:
  brief-toc links to toc, toc links to full text, full text links to toc

To DO:
- indices and references structure / headlines NOT hardcoded anymore!
  This causes too much trouble (e.g. links in brief-toc are broken!)
-->
<!--
  HACKS:
  - FOR GIF/SVG-VERSION: replace line in template match="srf:figure"
-->

<!--
  Entities used throughout the document (cannot be used because
  no DOCTYPE definition can be given. Or IS there a way???
-->
<!--
<!ENTITY space "<xsl:text> </xsl:text>"
<!ENTITY auml  "&#228;">
<!ENTITY ouml  "&#246;">
<!ENTITY uuml  "&#252;">
<!ENTITY Uuml  "&#220;">
<!ENTITY Ouml  "&#214;">
<!ENTITY Auml  "&#196;">
<!ENTITY ldquo "&#8220;">
<!ENTITY rdquo "&#8221;">
-->

<xsl:stylesheet id="srfXSL"
                version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:srf="http://www.xml-formats.org/ns/SRF"
                xmlns:bml="http://www.xml-formats.org/ns/BML">
<!-- including the following attribute makes things *much* worse! WHY??? -->
<!--                exclude-result-prefixes="srf bml xsl" -->

<xsl:strip-space elements="" />
<xsl:preserve-space elements="" />
<xsl:output method="xml"
       doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
       doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
       encoding="iso-8859-1"
       indent="no" />
<!--
XSL is a joke when it comes to "nice programming", so here's an
overview of the structure of this file:
-->
<!-- 1   Contents -->
<!-- 1.1 Brief Contents -->
<!-- 1.2 Full Contents -->
<!-- 2   Formatting the actual article -->
<!-- 2.1 The headlines -->
<!-- 2.2 Headline-template "heading" for TOC and Headlines in full text -->
<!-- 2.3 Acknowledgements -->
<!-- 2.4 Manual Page Breaks -->
<!-- 2.5 XHTML-tags: simply copy most of them -->
<!-- 2.6 Copy <pre>-subtree without processing! -->
<!-- 2.7 Footnote Definitions and where they are included -->
<!-- 2.8 Citations / Quotes (<quote> <blockquote>) -->
<!-- 2.9 Acronyms and Abbreviations -->
<!-- ... to be continued... -->
<!-- X The Root Template (srf:article) -->


<!-- 1   Contents -->
<!-- 1.1 Brief Contents -->
  <xsl:template mode="brief-toc" match="srf:chapter|srf:appendix">
    <!-- link to entries in toc ('toc_') instead of headlines in full text -->
    <xsl:variable name="tocID">toc_<xsl:value-of select="@id" /></xsl:variable>
    <h2><a href="#{$tocID}"><xsl:choose>
          <xsl:when test="local-name() = 'chapter'">
            <xsl:number level="multiple"
                        count="srf:chapter"
                        format="1 " />
          </xsl:when>
          <xsl:when test="local-name() = 'appendix'">
            Appendix<xsl:text> </xsl:text>
            <xsl:number level="multiple"
                        count="srf:appendix"
                        format="A: " />
          </xsl:when>
        </xsl:choose><xsl:value-of select="@title" /></a></h2>
  </xsl:template>

<!-- 1.2 Full Contents -->
  <xsl:template mode="toc"
                match="srf:chapter|srf:section|srf:subsection
                      |srf:appendix|srf:appsection|srf:appsubsection">
    <xsl:call-template name="heading">
      <xsl:with-param name="context" select="'toc'" />
    </xsl:call-template>
    <!-- recurse into the structure of the document... -->
    <xsl:apply-templates mode="toc"
                         select="srf:appsection|srf:appsubsection
                                 |srf:section|srf:subsection" />
  </xsl:template>

<!-- 2   Formatting the actual article -->

<!-- 2.1 The headlines -->
  <xsl:template match="srf:chapter|srf:section|srf:subsection
                       |srf:appendix|srf:appsection|srf:appsubsection">
    <xsl:call-template name="heading">
      <xsl:with-param name="context" select="'hdl'" />
    </xsl:call-template>
    <!-- <small class="noprint"><a href="#toc">[toc]</a></small> -->
    <!-- that's it with "structure"... both SRF and XHTML is mixed from here -->
    <xsl:apply-templates select="srf:section|srf:subsection
                                 |srf:appsection|srf:appsubsection
                                 |srf:footnote|srf:showfootnotes|srf:figure
                                 |srf:newpage|srf:blankpage
                                 |br|p|pre|q|table|code|img|ul|ol|blockquote
                                 |form|input|textarea" />
  </xsl:template>


<!-- 2.2 Headline-template "heading" for TOC and Headlines in full text -->
  <!-- this rather complex template is used for formatting the headlines
       BOTH in the toc and actual text -->
  <xsl:template name="heading">
    <!-- are we in toc or is this a h(ea)dl(ine) ??? -->
    <xsl:param name="context" select="'hdl'" /><!-- default! -->
    <!-- the difference is: in toc, the target is the headline in the full text,
         in the headline in the full text, the link target is in the toc -->
    <xsl:variable name="target">
      <!-- not using concat('toc_', @id) here because its a waste of space -->
      <xsl:if test="$context = 'toc'"><xsl:value-of select="@id" /></xsl:if>
      <xsl:if test="$context = 'hdl'">toc_<xsl:value-of select="@id" /></xsl:if>
    </xsl:variable>
    <xsl:variable name="backID">
      <xsl:if test="$context = 'toc'">toc_<xsl:value-of select="@id" /></xsl:if>
      <xsl:if test="$context = 'hdl'"><xsl:value-of select="@id" /></xsl:if>
    </xsl:variable>
    <!-- tags are always h2, h3 or h4 -->
    <xsl:variable name="headingTag">
      <xsl:choose>
        <xsl:when test="local-name() = 'chapter'
                     or local-name() = 'appendix'">h2</xsl:when>
        <xsl:when test="local-name() = 'section'
                     or local-name() = 'appsection'">h3</xsl:when>
        <xsl:otherwise>h4</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
      <!-- in toc, if it doesn't fit on one page, new page for appendices! -->
      <!-- at least 20 of {chapter|section|subsection} => new page for app -->
      <xsl:if test="$context = 'toc'
          and local-name() = 'appendix'
          and count(preceding-sibling::srf:appendix) = 0
          and count(/srf:article/srf:body/srf:chapter
                  |/srf:article/srf:body/srf:chapter/srf:section
                  |/srf:article/srf:body/srf:chapter/srf:section/srf:subsection)
              > 20"><!-- count({chapter|section|subsection}) > 20 -->
        <!-- xsl:attribute name="style">page-break-before:always;</xsl:attribute -->
        <br />
      	<p class="newpage">&#160;</p><!-- this is needed for printing duplex -->
      	<p class="newpage">&#160;</p><!-- this is needed for printing duplex -->
      </xsl:if>
    <xsl:element name="{$headingTag}"><!-- h2, h3 or h4 -->
      <!-- chapters and appendices always start with a new page (full text) -->
      <xsl:if test="$context = 'hdl' and $headingTag = 'h2'">
        <xsl:attribute name="class">chapter</xsl:attribute>
      </xsl:if>
      <a href="#{$target}" id="{$backID}" name="{$backID}">
        <xsl:choose>
          <xsl:when test="local-name() = 'chapter' or local-name() = 'section'
                       or local-name() = 'subsection'">
            <xsl:number level="multiple"
                        count="srf:chapter|srf:section|srf:subsection"
                        format="1.1.1 " />
          </xsl:when>
          <xsl:when test="local-name() = 'appendix'
                       or local-name() = 'appsection'
                       or local-name() = 'appsubsection'">
            Appendix<xsl:text> </xsl:text>
            <xsl:number level="multiple"
                        count="srf:appendix|srf:appsection|srf:appsubsection"
                        format="A.1.1: " />
          </xsl:when>
        </xsl:choose>
        <xsl:value-of select="@title" />
      </a>
    </xsl:element>
  </xsl:template>

<!-- 2.3 Acknowledgements -->
  <xsl:template match="srf:acknowledgements">
    <xsl:apply-templates select="p" />
  </xsl:template>

<!-- 2.4 Manual Page Breaks -->
  <!-- assures the following text is printed on a new page -->
  <xsl:template match="srf:newpage"><p class="newpage" /></xsl:template>
  <!-- when used before a chapter (or any other tag that causes the following
       text to be printed on a new page, this includes a blank page -->
  <xsl:template match="srf:blankpage"><p class="newpage">&#160;</p></xsl:template>

<!-- 2.5 XHTML-tags: simply copy most of them -->
  <!-- table: only, if it is not an indexed table! -->
  <xsl:template match="@*|p|font|a|em|strong|code|ul|ol|li
                       |table[@class='noindex']|tr|th|td|abbr|acronym|img">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>

  <!-- TO DO: Somehow remove all this superfluous xmlns="" -->

  <!-- for some reason, <br /> was turned to <br>CR</br> which is not valid! -->
  <xsl:template match="br">
    <br />
  </xsl:template>

<!-- 2.6 Copy <pre>-subtree without processing! -->
  <!-- Copy <pre>abc</pre> without any processing! -->
  <xsl:template match="pre">
    <xsl:copy-of select="." />
  </xsl:template>

<!-- 2.7 Footnote Definitions and where they are included -->
  <xsl:template match="srf:footnote">
    <xsl:variable name="target" select="concat(@localCode, @localID)" />
    <xsl:variable name="backID" select="concat($target, 'src')" />
    <!-- avoid whitespace here! -->
    <sup><small><a id="{$backID}"
         name="{$backID}"
         href="#{$target}"><xsl:value-of select="@localID" /></a></small></sup>
  </xsl:template>

  <xsl:template match="srf:showfootnotes">
    <xsl:variable name="local" select="@localCode" />
    <p>
      Footnotes:<br />
      <xsl:for-each select="//srf:footnote[(@localCode=$local) and text()]">
        <xsl:sort data-type="number" select="@localID" />
        <xsl:variable name="target" select="concat(@localCode, @localID)" />
            <xsl:variable name="backID" select="concat($target, 'src')" />
        <small>
          <a name="{$target}"
             id="{$target}"
             href="#{$backID}"><xsl:value-of select="@localID" /></a>
          <xsl:text> </xsl:text><!-- make sure whitespace is in between -->
          <xsl:apply-templates select="@*|node()|a|em|strong" />
        </small>
        <br />
      </xsl:for-each>
    </p>
  </xsl:template>

<!-- 2.8 Citations / Quotes (<quote> <blockquote>) -->
  <!-- quotes -->
  <xsl:template match="q">
    &#8220;<xsl:apply-templates select="@*|node()" />&#8221;
    <xsl:if test="@cite">
      (<a href="#{@cite}"><cite>[<xsl:value-of select="@cite" />]</cite></a>)</xsl:if></xsl:template><!-- avoid superfluous whitespace! -->

  <xsl:template match="blockquote">
    <blockquote cite="@cite"><p>&#8220;<xsl:apply-templates select="./p/node()" />&#8221;
    <xsl:if test="@cite">
      (<a href="#{@cite}"><cite>[<xsl:value-of select="@cite" />]</cite></a>)
    </xsl:if></p></blockquote>
  </xsl:template>

<!-- 2.9 Acronyms and Abbreviations -->
  <!-- useful especially for printing! -->
  <xsl:template match="abbr|acronym">
    <xsl:variable name="nid"><xsl:value-of select="local-name()" />_<xsl:value-of select="@id" /></xsl:variable>
    <em class="{local-name()}"><a id="{$nid}" name="{$nid}"><xsl:copy><xsl:copy-of select="@*" /><xsl:apply-templates /></xsl:copy></a></em><!--
    <xsl:text> </xsl:text>--><em class="printonly">[<xsl:value-of select="@title" />]</em>
  </xsl:template>

  <!-- links, with cross-references, tighter template is matched (see below) -->
  <xsl:template match="a">
    <xsl:copy-of select="." />
    <xsl:if test="@href and not(@class='explicit')">
      <xsl:text> </xsl:text><em class="printonly">[<xsl:value-of select="@href" />]</em>
    </xsl:if>
  </xsl:template>

  <!-- XXX FIX THIS PLEASE!!! XXX -->
  <xsl:template match="a[name(child::node())='dfn']">
    <xsl:copy-of select="." />
    <xsl:apply-templates select="dfn" mode="justAnchor" />
    <xsl:if test="@href and not(@class='explicit')">
      <xsl:text> </xsl:text><em>[<xsl:value-of select="@href" />]</em>
    </xsl:if>
  </xsl:template>
  <xsl:template match="dfn" mode="justAnchor">
    <xsl:variable name="nid"><xsl:value-of select="local-name()" />_<xsl:value-of select="@id" /></xsl:variable>
    <a id="{$nid}" name="{$nid}"><xsl:text> </xsl:text></a>
  </xsl:template>

  <!-- fix cross-references -->
  <xsl:template match="a[@class='crossRef']">
    <xsl:variable name="target" select="@href" />
    <xsl:apply-templates select="/srf:article/srf:body/srf:chapter[@id=$target]
                                 |/srf:article/srf:body/srf:chapter/srf:section[@id=$target]
                                 |/srf:article/srf:body/srf:chapter/srf:section/srf:subsection[@id=$target]
                                 |/srf:article/srf:body/srf:appendix[@id=$target]
                                 |/srf:article/srf:body/srf:appendix/srf:appsection[@id=$target]
                                 |/srf:article/srf:body/srf:appendix/srf:appsection/srf:appsubsection[@id=$target]
                                 |//srf:figure[@id=$target]
                                 |//table[@id=$target]"
                         mode="crossRefFull" />
  </xsl:template>

  <!-- used by "fix cross-references" and index builders -->
  <!-- XXX remove "chapter" for consistence with figures and table and language independence! -->
  <xsl:template match="srf:chapter|srf:section|srf:subsection|srf:subsubsubsection
                       |srf:appendix|srf:appsection|srf:appsubsection
                       |srf:figure|table"
                mode="crossRefFull">
    <xsl:variable name="target" select="@id" />
    <xsl:variable name="fullTarget">
      <xsl:choose>
        <xsl:when test="local-name(.) = 'figure'">Figure_</xsl:when>
        <xsl:when test="local-name(.) = 'table'">Table_</xsl:when>
      </xsl:choose><xsl:value-of select="@id" />
    </xsl:variable>
    <xsl:variable name="title" select="@title" />
    <a href="#{$fullTarget}"><xsl:if test="local-name(.) = 'chapter' or local-name(.) = 'section' or local-name(.) = 'subsection' or local-name(.) = 'subsubsubsection'">chapter</xsl:if>
      <xsl:if test="local-name(.) = 'appendix' or local-name(.) = 'appsection' or local-name(.) = 'appsubsection'">appendix</xsl:if>
      <xsl:if test="local-name(.) = 'table'">table</xsl:if>
      <xsl:if test="local-name(.) = 'figure'">figure</xsl:if>
      <xsl:text> </xsl:text>
      <em class="crossRef">
        <xsl:apply-templates select="/srf:article/srf:body/srf:chapter[@id=$target]
                                     |/srf:article/srf:body/srf:chapter/srf:section[@id=$target]
                                     |/srf:article/srf:body/srf:chapter/srf:section/srf:subsection[@id=$target]
                                     |/srf:article/srf:body/srf:appendix[@id=$target]
                                     |/srf:article/srf:body/srf:appendix/srf:appsection[@id=$target]
                                     |/srf:article/srf:body/srf:appendix/srf:appsection/srf:appsubsection[@id=$target]
                                     |//srf:figure[@id=$target]
                                     |//table[@id=$target]"
                             mode="crossRefNum" /></em></a></xsl:template>

  <xsl:template match="srf:chapter|srf:section|srf:subsection"
                mode="crossRefNum">
      <xsl:number level="multiple"
                count="srf:chapter|srf:section|srf:subsection"
                format="1.1.1" /></xsl:template>

  <xsl:template match="srf:appendix|srf:appsection|srf:appsubsection"
                mode="crossRefNum">
      <xsl:number level="multiple"
                count="srf:appendix|srf:appsection|srf:appsubsection"
                format="A.1.1" /></xsl:template>

  <!-- wrap definitions in <a id="DFN" name="DFN">-tags -->
  <!-- surround <dfn>-Tags with <em class="dfn">-tags -->
  <!-- if external URL is given, add this to the <a>-tag -->
  <xsl:template match="dfn">
    <xsl:variable name="nid"><xsl:value-of select="local-name()" />_<xsl:value-of select="@id" /></xsl:variable>
    <em class="{local-name()}"><a id="{$nid}" name="{$nid}"><xsl:copy><xsl:copy-of select="@*" /><xsl:apply-templates /></xsl:copy></a></em>
  </xsl:template>
    <!-- <em class="{local-name()}"><xsl:element name="a"><xsl:attribute name="id"><xsl:value-of select="$nid" /></xsl:attribute><xsl:attribute name="name"><xsl:value-of select="$nid" /></xsl:attribute><xsl:if test="@href"><xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute></xsl:if><xsl:copy><xsl:copy-of select="@*" /><xsl:apply-templates /></xsl:copy></xsl:element></em> -->
  <!-- if this is split into multiple lines, trailing whitespace
       is the result... unfortunately :-( -->

  <!-- build index of definitions (inside a table) -->
  <xsl:template match="dfn|abbr|acronym" mode="defIndexTable">
    <xsl:variable name="id" select="@id" />
    <xsl:variable name="sectionID">
      <xsl:choose>
        <xsl:when test="ancestor::srf:subsection/@id">
          <xsl:value-of select="ancestor::srf:subsection/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:section/@id">
          <xsl:value-of select="ancestor::srf:section/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:chapter/@id">
          <xsl:value-of select="ancestor::srf:chapter/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:appsubsection/@id">
          <xsl:value-of select="ancestor::srf:appsubsection/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:appsection/@id">
          <xsl:value-of select="ancestor::srf:appsection/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:appendix/@id">
          <xsl:value-of select="ancestor::srf:appendix/@id" />
        </xsl:when>
      </xsl:choose>
    </xsl:variable>
    <tr class="terms">
      <td class="terms">
        <a href="#{local-name()}_{$id}">
          <xsl:choose>
            <xsl:when test="@title">
              <xsl:value-of select="@title" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="text()" />
            </xsl:otherwise>
          </xsl:choose>
        </a>
      </td>
      <td class="terms">
        <xsl:apply-templates select="/srf:article/srf:body/srf:chapter[@id=$sectionID]
                        |/srf:article/srf:body/srf:chapter/srf:section[@id=$sectionID]
                        |/srf:article/srf:body/srf:chapter/srf:section/srf:subsection[@id=$sectionID]
                        |/srf:article/srf:body/srf:appendix[@id=$sectionID]
                        |/srf:article/srf:body/srf:appendix/srf:appsection[@id=$sectionID]
                        |/srf:article/srf:body/srf:appendix/srf:appsection/srf:appsubsection[@id=$sectionID]"
                             mode="crossRefFull" />
      </td>
    </tr>
  </xsl:template>

  <!-- CURRENTLY USED ALTERNATIVE: build index of definitions (as a list) -->
  <xsl:template match="dfn|abbr|acronym" mode="defIndexList">
    <xsl:variable name="id" select="@id" />
    <xsl:variable name="sectionID">
      <xsl:choose>
        <xsl:when test="ancestor::srf:subsection/@id">
          <xsl:value-of select="ancestor::srf:subsection/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:section/@id">
          <xsl:value-of select="ancestor::srf:section/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:chapter/@id">
          <xsl:value-of select="ancestor::srf:chapter/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:appsubsection/@id">
          <xsl:value-of select="ancestor::srf:appsubsection/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:appsection/@id">
          <xsl:value-of select="ancestor::srf:appsection/@id" />
        </xsl:when>
        <xsl:when test="ancestor::srf:appendix/@id">
          <xsl:value-of select="ancestor::srf:appendix/@id" />
        </xsl:when>
      </xsl:choose>
    </xsl:variable>
      <span class="terms">
      <a href="#{local-name()}_{$id}">
        <xsl:choose>
          <xsl:when test="local-name() = 'dfn'">
            <xsl:choose>
              <xsl:when test="@title">
                <xsl:value-of select="@title" />
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="text()" />
              </xsl:otherwise>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise><!-- abbr and acronym -->
            <xsl:value-of select="text()" />:
            <xsl:value-of select="@title" />
          </xsl:otherwise>
        </xsl:choose>
      </a><xsl:text> (</xsl:text>
      <xsl:apply-templates select="/srf:article/srf:body/srf:chapter[@id=$sectionID]
                        |/srf:article/srf:body/srf:chapter/srf:section[@id=$sectionID]
                        |/srf:article/srf:body/srf:chapter/srf:section/srf:subsection[@id=$sectionID]
                        |/srf:article/srf:body/srf:appendix[@id=$sectionID]
                        |/srf:article/srf:body/srf:appendix/srf:appsection[@id=$sectionID]
                        |/srf:article/srf:body/srf:appendix/srf:appsection/srf:appsubsection[@id=$sectionID]"
                           mode="crossRefFull" />)</span><br />
  </xsl:template>

  <!-- enumerate tables except those not indexed -->
  <xsl:template match="table[not(@class='noindex')]">
    <p class="center"><a id="Table_{@id}" name="Table_{@id}"><xsl:text> </xsl:text></a>
    <xsl:copy>
      <xsl:copy-of select="@*" />
      <!--
      <caption style="caption-side:bottom;">
        <strong><small>
          Table<xsl:text> </xsl:text><xsl:apply-templates select="self::table" mode="crossRefNum" />:
          <xsl:value-of select="caption/text()" />
        </small></strong>
      </caption>
      -->
      <xsl:apply-templates select="tr" />
    </xsl:copy>
    </p>
    <p style="text-align:center;">
        <strong><small>
          Table<xsl:text> </xsl:text><xsl:apply-templates select="self::table" mode="crossRefNum" />:
          <xsl:value-of select="caption/text()" />
        </small></strong>
    </p>
    <p />
  </xsl:template>

  <!-- build index of tables -->
  <xsl:template match="table[not(@class='noindex')]" mode="tableIndex">
    <tr>
      <td>
        <a href="#Table_{@id}">
          Table <xsl:text> </xsl:text><xsl:apply-templates select="self::table" mode="crossRefNum" />
        </a>
      </td>
      <td>
        <strong><xsl:value-of select="caption/text()" /></strong><br />
        <xsl:value-of select="@summary" />
      </td>
    </tr>
  </xsl:template>

  <!-- enumerate figures -->
  <xsl:template match="srf:figure">
  <!--
    <xsl:variable name="format" select="@preferredFormat" />
    <xsl:variable name="width" select="@width * @scale" />
    <xsl:variable name="height" select="@height * @scale" />
    -->
    <xsl:variable name="format" select="'gif'" />
    <xsl:variable name="width" select="@width" />
    <xsl:variable name="height" select="@height" />

    <p><a id="Figure_{@id}" name="Figure_{@id}"><xsl:text> </xsl:text></a></p>
    <div style="text-align:center;">
    <table class="border">
      <!--
      <caption style="caption-side:bottom;">
        <strong><small>
          Figure<xsl:text> </xsl:text><xsl:apply-templates select="self::srf:figure" mode="crossRefNum" />:
          <xsl:value-of select="caption/text()" />
        </small></strong>
      </caption>
      -->
          <tr>
            <td>
              <xsl:if test="$format = 'svg'">
                <!--  name="{@id}" -->
            <embed src="{@src}.{$format}"
                   width="{$width}" height="{$height}"
                   type="image/svg-xml"
                   pluginspage="http://www.adobe.com/svg/viewer/install/" />
          </xsl:if>
              <xsl:if test="$format = 'gif'">
            <img src="{@src}.{$format}" alt="{@src}"
                 width="{$width}" height="{$height}" />
          </xsl:if>
            </td>
      </tr>
    </table>
    <p class="center">
        <strong><small>
          Figure<xsl:text> </xsl:text><xsl:apply-templates select="self::srf:figure" mode="crossRefNum" />:
          <xsl:value-of select="caption/text()" />
        </small></strong>
    </p>
    </div>
    <p />
  </xsl:template>

  <xsl:template match="srf:figure" mode="crossRefNum">
    <xsl:choose>
      <xsl:when test="./ancestor-or-self::srf:appendix"><xsl:number level="multiple"
                count="srf:appendix|srf:appsection|srf:appsubsection"
                format="A.1.1" /></xsl:when>
      <!-- otherwise, it must be a chapter or sub... thereof -->
      <xsl:otherwise><xsl:number level="multiple"
                count="srf:chapter|srf:section|srf:subsection"
                format="1.1.1" /></xsl:otherwise>
    </xsl:choose>
    <!-- <xsl:if test="preceding-sibling::srf:figure or following-sibling::srf:figure">
           <xsl:variable name="figureID" select="count(preceding-sibling::srf:figure)+1" />
             (<xsl:value-of select="$figureID" />)</xsl:if></xsl:template> -->
    <!-- This was *very* tricky! If figures are embedded in a table, preceding-sibling
         doesn't work. So I had to find a way of expressing "preceding somewhere
         under the common subsection, section or chapter... after some trial
         and error, however, it finally worked!!! -->
    <xsl:choose>
      <xsl:when test="count(ancestor::srf:subsection/descendant::srf:figure) > 1
                      or count(ancestor::srf:appsubsection/descendant::srf:figure) > 1">
        <xsl:variable name="secID" select="ancestor::srf:subsection/@id" />
        <xsl:variable name="appID" select="ancestor::srf:appsubsection/@id" />
        <xsl:variable name="figureID" select="count(preceding::srf:figure[ancestor::srf:subsection[@id = $secID]
                                                                         |ancestor::srf:appsubsection[@id = $appID]])+1" />
          (<xsl:value-of select="$figureID" />)</xsl:when>
      <xsl:when test="(count(ancestor::srf:section/descendant::srf:figure) > 1
                           and (1 > count(ancestor::srf:subsection/descendant::srf:figure)))
                      or (count(ancestor::srf:appsection/descendant::srf:figure) > 1
                           and (1 > count(ancestor::srf:appsubsection/descendant::srf:figure)))">
        <xsl:variable name="secID" select="ancestor::srf:section/@id" />
        <xsl:variable name="appID" select="ancestor::srf:appsection/@id" />
        <xsl:variable name="figureID" select="count(preceding::srf:figure[ancestor::srf:section[@id = $secID] | ancestor::srf:appsection[@id = $appID]])+1" />
          (<xsl:value-of select="$figureID" />)</xsl:when>
      <xsl:when test="(count(ancestor::srf:chapter/descendant::srf:figure) > 1 and 1 > count(ancestor::srf:section/descendant::srf:figure))
                      or (count(ancestor::srf:appendix/descendant::srf:figure) > 1 and 1 > count(ancestor::srf:appsection/descendant::srf:figure))">
        <xsl:variable name="secID" select="(ancestor::srf:chapter|ancestor::srf:appendix)/@id" />
        <xsl:variable name="appID" select="ancestor::srf:appendix/@id" />
        <xsl:variable name="figureID" select="count(preceding::srf:figure[ancestor::srf:chapter[@id = $secID] | ancestor::srf:appendix[@id = $appID]])+1" />
          (<xsl:value-of select="$figureID" />)</xsl:when>
    </xsl:choose></xsl:template><!-- pay attention to superfluous whitespace! -->

  <!-- The same for tables... -->
  <xsl:template match="table" mode="crossRefNum">
    <xsl:choose>
      <xsl:when test="./ancestor-or-self::srf:appendix"><xsl:number level="multiple"
                count="srf:appendix|srf:appsection|srf:appsubsection"
                format="A.1.1" /></xsl:when>
      <!-- otherwise, it must be a chapter or sub... thereof -->
      <xsl:otherwise><xsl:number level="multiple"
                count="srf:chapter|srf:section|srf:subsection"
                format="1.1.1" /></xsl:otherwise>
    </xsl:choose>
    <!-- see above...
        <xsl:if test="preceding-sibling::table or following-sibling::table">
          <xsl:variable name="tableID" select="count(preceding-sibling::table)+1" />
            (<xsl:value-of select="$tableID" />)</xsl:if>
    -->
    <xsl:choose>
      <xsl:when test="count(ancestor::srf:subsection/descendant::table) > 1
                      or count(ancestor::srf:appsubsection/descendant::table) > 1">
        <xsl:variable name="secID" select="ancestor::srf:subsection/@id" />
        <xsl:variable name="appID" select="ancestor::srf:appsubsection/@id" />
        <xsl:variable name="figureID" select="count(preceding::table[ancestor::srf:subsection[@id = $secID]
                                                                         |ancestor::srf:appsubsection[@id = $appID]])+1" />
          (<xsl:value-of select="$figureID" />)</xsl:when>
      <xsl:when test="(count(ancestor::srf:section/descendant::table) > 1
                           and (1 > count(ancestor::srf:subsection/descendant::table)))
                      or (count(ancestor::srf:appsection/descendant::table) > 1
                           and (1 > count(ancestor::srf:appsubsection/descendant::table)))">
        <xsl:variable name="secID" select="ancestor::srf:section/@id" />
        <xsl:variable name="appID" select="ancestor::srf:appsection/@id" />
        <xsl:variable name="tableID" select="count(preceding::table[ancestor::srf:section[@id = $secID] | ancestor::srf:appsection[@id = $appID]])+1" />
          (<xsl:value-of select="$tableID" />)</xsl:when>
      <xsl:when test="(count(ancestor::srf:chapter/descendant::table) > 1 and 1 > count(ancestor::srf:section/descendant::table))
                      or (count(ancestor::srf:appendix/descendant::table) > 1 and 1 > count(ancestor::srf:appsection/descendant::table))">
        <xsl:variable name="secID" select="(ancestor::srf:chapter|ancestor::srf:appendix)/@id" />
        <xsl:variable name="appID" select="ancestor::srf:appendix/@id" />
        <xsl:variable name="tableID" select="count(preceding::table[ancestor::srf:chapter[@id = $secID] | ancestor::srf:appendix[@id = $appID]])+1" />
          (<xsl:value-of select="$tableID" />)</xsl:when>
    </xsl:choose></xsl:template><!-- pay attention to superfluous whitespace! -->


  <!-- build index of figures -->
  <xsl:template match="srf:figure" mode="figureIndex">
    <tr>
      <td>
        <a href="#Figure_{@id}">
          Figure<xsl:text> </xsl:text><xsl:apply-templates select="self::srf:figure" mode="crossRefNum" />
        </a>
      </td>
      <td>
        <strong><xsl:value-of select="caption/text()" /></strong><br />
        <xsl:value-of select="@summary" />
      </td>
    </tr>
  </xsl:template>

  <!-- format bibliography -->

  <xsl:template match="srf:bibliography" mode="bib">
    <xsl:apply-templates select="tr" />
  </xsl:template>

  <!-- These 2 templates make links from all <cite>-tags to the relevant references -->
  <xsl:template match="cite[not(@title)]">
    <xsl:variable name="refe" select="substring(text(),2,string-length(text())-2)" />
    <xsl:variable name="refID" select="count(preceding::cite[not(@title) and text() = concat('[', $refe, ']')])" />
    <a href="#{$refe}" id="{$refe}_{$refID}" name="{$refe}_{$refID}"><xsl:copy><xsl:apply-templates /></xsl:copy></a></xsl:template>

  <xsl:template match="cite[@title]">
    <xsl:variable name="refe" select="@title" />
    <!-- xsl:variable name="refID" select="count(preceding::cite[@title])" / -->
    <xsl:variable name="refID" select="count(preceding::cite[@title = $refe])" />
    <a href="#{$refe}" id="{$refe}_{$refID}" name="{$refe}_{$refID}"><xsl:copy><xsl:apply-templates /></xsl:copy></a></xsl:template>
  <!-- ================================================================ -->

  <!-- build references from own file! -->
  <!-- for each reference, build "used at" list -->

  <!-- create a list of keywords -->

  <xsl:template match="bml:keywords">
    <xsl:for-each select="bml:keyword"><xsl:value-of select="text()" /><xsl:if test="position() &lt; last()">,<xsl:text> </xsl:text></xsl:if></xsl:for-each>
  </xsl:template>

<!-- X The root template (srf:article) -->
  <!-- The HTML-PMS-Paper Frame -->
  <xsl:template match="srf:article">
    <!-- These are the numbers for the Indices and References sections -->
    <!-- xsl:variable name="sectionCountInd" select="count(/srf:article/srf:body/srf:chapter) + 1" />
    <xsl:variable name="sectionCountRef" select="count(/srf:article/srf:body/srf:chapter) + 2" / -->
    <xsl:variable name="sectionCountInd">E</xsl:variable>
    <xsl:variable name="sectionCountRef">F</xsl:variable>

    <xsl:variable name="title"       select="./bml:entry/*/bml:title/text()" />
    <xsl:variable name="date">
      <xsl:value-of select="./bml:entry/*/bml:month/text()" /><xsl:text>, </xsl:text>
      <xsl:value-of select="./bml:entry/*/bml:year/text()" />
    </xsl:variable>
    <xsl:variable name="location"    select="./bml:entry/*/bml:url/text()" />
    <xsl:variable name="authorName">
      <xsl:value-of select="./bml:entry/*/bml:authors/bml:author/@first" /><xsl:text> </xsl:text>
      <xsl:if test="./bml:entry/*/bml:authors/bml:author/@middle">
        <xsl:value-of select="./bml:entry/*/bml:authors/bml:author/@middle" /><xsl:text> </xsl:text>
      </xsl:if>
      <xsl:if test="./bml:entry/*/bml:authors/bml:author/@preLast">
        <xsl:value-of select="./bml:entry/*/bml:authors/bml:author/@preLast" /><xsl:text> </xsl:text>
      </xsl:if>
      <xsl:value-of select="./bml:entry/*/bml:authors/bml:author/@last" />
    </xsl:variable>
    <xsl:variable name="authorEMail" select="./bml:entry/*/bml:authors/bml:author/@eMail" />
    <xsl:variable name="abstract"    select="normalize-space(./bml:entry/*/bml:abstract/text())" />
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
    <meta name="Author" content="{$authorName}" />
    <meta name="description" content="{$abstract}" />
    <xsl:element name="meta">
      <xsl:attribute name="name">keywords</xsl:attribute>
      <xsl:attribute name="content"><xsl:apply-templates select="./bml:entry/*/bml:keywords" /></xsl:attribute>
    </xsl:element>
    <!-- link rel="stylesheet" type="text/css" href="doc.css" / -->
    <style type="text/css">
/* ====================    project thesis:    ==================== */

body {
  background-color: #FFFFEE;
  margin: 0.5cm;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

small {
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

/* FROM doc.css */
.center {
  text-align: center;
}

.pending {
  color:#FF0000;
}

.note {
  color:#008800;
  font-style:italic;
}

tr, td, p {
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

small {
  font-size:9pt;
}

/* Netscape 4.78 does not know the dfn-Tag, em.dfn is a workaround! */
em.dfn, dfn {
/*  background-color: #FFFF66;  */
  font-style:italic;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

em.abbr, abbr {
/*  background-color: #FF66FF;  */
  color: #007700;
}

em.acronym, acronym {
/*  background-color: #66FFFF;  */
  color: #007700;
}

a:link    { color:#3333AA; text-decoration:none;}
a:visited { color:#111188; text-decoration:none;}
a:hover   { color:#662222; text-decoration:underline;}
a:active  { background-color:EEEEFF; color:#662222; text-decoration:underline;}
a:focus   { background-color:EEEEFF; color:#662222; text-decoration:underline;}

/* This hides the "used in" column in the bibliography */
td.used {
  display: none;
}

cite {
  color: #6666FF;
}

body div {
  padding: 0em;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

body h1 {
  text-align: center;
  margin: 2cm;
  font-size:24pt;
}

body h2.chapter {
  page-break-before: always;
  padding-top: 2em;
  margin-top: 2em;
  border-top-width: thick;
  border-top-style: groove;
  border-top-color: rgb(128,128,255);
}

/* Used to format the author(s) on the first page */
p.author {
  text-align: center;
  margin: 2cm;
}

/* This is used, e.g., for "Diplomarbeit" on the first page */
p.type {
  text-align: center;
  margin: 2cm;
}

pre {
  font-size:10pt;
}

table {
  border-collapse:collapse;
}

ul.inTable {
  margin-left:1.5em;
  font-size:9pt;
  text-align:left;
}

td, th {
  padding:2pt;
  font-size:11pt;
}

td, tr, th {
  vertical-align:top;
}

table.border, table.noindex {
  border-width: 2px;
  border-style: solid;
  border-color: rgb(0,0,0);
}

table.border td, table.border tr, table.border th,
table.noindex td, table.noindex tr, table.noindex th {
  border-width: 1px;
  border-style: solid;
  border-color: rgb(64,64,64);
}

th {
  background-color: #EEFFFF;
}

table.references {
  margin-right: 1cm;
  font-size:8pt;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

.terms {
  font-size:10pt;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

table.references tr {
  font-size:8pt;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

table.references tr.unread {
  /* background-color: #FFAAAA; */
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

table.references tr td {
  font-size:8pt;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

td.citeref {
  vertical-align: top;
  font-weight: bold;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

td.citation {
  vertical-align: top;
  font-family: Verdana, Helvetica, Arial, sans-serif;
}

span.comment {
  color:#008000;
}

span.keyword {
  color:#000080;
  font-weight:bold;
}

span.literal {
  color:#0000ff;
}

div.contents h2, h3, h4, h5, h6 {
  margin: 0em;
  padding-top: 0em;
  padding-bottom: 0em;
}

div.contents h2 {
  padding-left: 0em;
  font-size: 14pt;
  line-height: 16pt;
}

div.contents h3 {
  padding-left: 2em;
  font-size: 12pt;
  line-height: 14pt;
}

div.contents h4 {
  padding-left: 4em;
  font-size: 10pt;
  line-height: 12pt;
}

div.contents h5 {
  padding-left: 6em;
  font-size: 8pt;
  line-height: 10pt;
}

@media print {
  body {
    background-color: #FFFFFF;
    margin: 0cm;
    font-size: 11pt;
  }

  .newpage {
    page-break-before: always;
  }

  p, cite, pre, li, blockquote {
    text-align: justify;
    font-size: 11pt;
  }

  ul.inTable li {
    text-align: left;
    font-size: 8pt;
  }

  pre {
    font-size:9pt;
  }

  small {
    font-size:8pt;
  }

  td, th {
    text-align: justify;
    font-size: 10pt;
  }

  body h2.chapter {
    page-break-before: always;
    padding-top: 0em;
    margin-top: 0em;
    border-top-style: none;
  }

  td.used {
    display: none;
  }

  .noprint {
    display: none;
  }
}

@media screen {
  .printonly {
    display: none;
  }

  .newpage {
    page-break-before: always;
    display: none;
  }
}

    </style>
    <title><xsl:value-of select="$title" /></title>
  </head>
  <body>
    <div class="noprint">
    <p class="center">
      <small>
        <a href="http://www.teamXweb.com/index.shtml" id="top" name="top">[home]</a>
      </small>
    </p>

    <!-- heading -->
    <p>
      <small>
        This page:
        <a href="{$location}">
          <code><xsl:value-of select="$location" /></code></a>
        <br />
        <a href="mailto:{$authorEMail}">
          <i><xsl:value-of select="$authorName" /></i></a>, <xsl:value-of select="$date" />
      </small>
    </p>
    <p>
      <i>
        Lehr- und Forschungseinheit für Programmier- und Modellierungssprachen,
        <br />
        Institut für Informatik der Ludwigs- Maximilians-Universität München
      </i>
    </p>
    </div>

    <table class="printonly" style="width:100%;">
      <tr>
        <td style="text-align:center;width:250pt;">
          <strong style="font-size:14pt;">INSTITUT FÜR INFORMATIK</strong><br />
          Lehr- und Forschungseinheit für<br />
          Programmier- und Modellierungssprachen<br />
          <br />
          <table style="width:100%;">
            <tr>
              <td style="width:50%;text-align:left;">
                Oettingenstraße 67
              </td>
              <td style="width:50%;text-align:right;">
                D-80538 München
              </td>
            </tr>
          </table>
        </td>
        <td style="text-align:right;">
          <img src="ext/LMUlogoFarbe.gif" alt="[LMU Logo]" />
        </td>
      </tr>
    </table>
    <!-- end of heading -->

    <h1><xsl:value-of select="$title" /></h1>

    <p class="author"><xsl:value-of select="$authorName" /></p>

    <p class="type">Diplomarbeit</p>

    <div style="text-align:center">
      <table>
        <tr><td>Beginn der Arbeit:</td><td>22.07.2002</td></tr>
        <tr><td>Abgabe der Arbeit:</td><td>12.12.2002</td></tr>
        <tr><td>Betreuer:</td>
            <td>
              Prof. Dr. Fran&#231;ois Bry<br />
              Dipl.-Inform. Michael Kraus
            </td>
        </tr>
      </table>
    </div>

	<p class="newpage">&#160;</p><!-- this is needed for printing duplex -->
        <!-- remove this, if you don't need it. If you don't understand it,
             you sure do not need it ;-) -->
        <div class="printonly">
      <h2 class="chapter" style="margin-top:10cm;">Erklärung</h2>
      <p style="margin-bottom:2cm;">
        Hiermit versichere ich, dass ich diese Diplomarbeit selbständig verfasst
        habe. Ich habe dazu keine anderen als die angegebenen Quellen und Hilfsmittel
        verwendet.
      </p>
      <p>München, den 12. Dezember 2002</p>
    </div>

	<p class="newpage">&#160;</p><!-- this is needed for printing duplex -->

    <h2 class="chapter">Abstract</h2>
    <div class="abstract">
      <blockquote cite="http://www.pms.informatik.uni-muenchen.de/lehre/projekt-diplom-arbeit/navigation-track/doc/thesis.shtml">
        <xsl:value-of select="$abstract" />
      </blockquote>
    </div>

    <h2 class="abstract">Keywords</h2>
    <p>
      <xsl:apply-templates select="./bml:entry/*/bml:keywords" />
    </p>

    <h2 class="abstract">Availability on the Web</h2>
    <p>
      <a href="{$location}">
          <code><xsl:value-of select="$location" /></code></a>
    </p>
    <p><strong>Note:</strong>
      This work has been optimized for being viewed on the Web.
      If you need to print the document, use the PDF version available
      at the given URI. If you want to read the document online, use
      the HTML version also available there.
    </p>


    <p class="newpage">&#160;</p><!-- this is needed for printing duplex -->

    <xsl:if test="//srf:acknowledgements">
      <h2 class="chapter">Acknowledgements</h2>
      <xsl:apply-templates select="//srf:acknowledgements" />
    </xsl:if>

	<p class="newpage">&#160;</p><!-- this is needed for printing duplex -->

    <h2 class="chapter"><a name="brief-toc" id="brief-toc">Brief Contents</a></h2>
    <div class="contents">
      <xsl:apply-templates mode="brief-toc"
                           select="srf:body/srf:chapter|srf:body/srf:appendix" />
      <h2><a href="#ind">
        Appendix<xsl:text> </xsl:text><xsl:value-of select="$sectionCountInd" />:
        <xsl:text> </xsl:text>
        Indices</a></h2>
      <h2><a href="#ref">
        Appendix<xsl:text> </xsl:text><xsl:value-of select="$sectionCountRef" />:
        <xsl:text> </xsl:text>
        References</a></h2>
    </div>

	<p class="newpage">&#160;</p><!-- this is needed for printing duplex -->

    <h2 class="chapter"><a name="toc" id="toc">Contents</a></h2>
    <div class="contents">
      <xsl:apply-templates select="srf:body/srf:chapter|srf:body/srf:appendix" mode="toc" />
      <h2><a href="#ind">
        Appendix<xsl:text> </xsl:text><xsl:value-of select="$sectionCountInd" />:
        <xsl:text> </xsl:text>
        Indices</a></h2>
      <h3><a href="#termsIndex">
        Appendix<xsl:text> </xsl:text><xsl:value-of select="$sectionCountInd" />
        <xsl:text>.1: </xsl:text>
        Terms</a></h3>
      <h3><a href="#acrsIndex">
        Appendix<xsl:text> </xsl:text><xsl:value-of select="$sectionCountInd" />
        <xsl:text>.2: </xsl:text>
        Acronyms and Abbreviations</a></h3>
      <h3><a href="#tablesIndex">
        Appendix<xsl:text> </xsl:text><xsl:value-of select="$sectionCountInd" />
        <xsl:text>.3: </xsl:text>
        Tables</a></h3>
      <h3><a href="#figuresIndex">
        Appendix<xsl:text> </xsl:text><xsl:value-of select="$sectionCountInd" />
        <xsl:text>.4: </xsl:text>
        Figures</a></h3>
      <h2><a href="#ref">
        Appendix<xsl:text> </xsl:text><xsl:value-of select="$sectionCountRef" />:
        <xsl:text> </xsl:text>
        References</a></h2>
    </div>

  	<p class="newpage">&#160;</p><!-- this is needed for printing duplex -->

    <!-- paper -->
    <xsl:apply-templates select="srf:body/srf:chapter|srf:body/srf:appendix
                                |srf:body/srf:newpage|srf:body/srf:blankpage" />

    <!-- Indices: Terms and Tables -->
    <h2 class="chapter"><a id="ind" name="ind">
      <xsl:value-of select="$sectionCountInd" />
      <xsl:text> </xsl:text>
      Indices</a></h2>
    <h3><a id="termsIndex" name="termsIndex">
      <xsl:value-of select="$sectionCountInd" />
      <xsl:text>.1 </xsl:text>
      Terms</a></h3>
    <p>
      The following list gives an overview of all terms that are
      used throughout this paper including links to the actual
      definitions as well as the sections where they have been given:
    </p>
    <xsl:for-each select="//dfn">
      <xsl:sort data-type="text" select="." />
      <xsl:apply-templates select="." mode="defIndexList" />
    </xsl:for-each>
    <!-- Alternative: with a table -->
    <!-- table width="70%" align="center">
      <tr><th width="70%">Term</th><th width="30%">Defined in...</th></tr>
      <xsl:for-each select="//dfn">
        <xsl:sort data-type="text" select="." />
        <xsl:apply-templates select="." mode="defIndex" />
      </xsl:for-each>
    </table -->
    <p />
    <br />

    <h3><a id="acrsIndex" name="acrsIndex">
      <xsl:value-of select="$sectionCountInd" />
      <xsl:text>.2 </xsl:text>
      Acronyms and Abbreviations</a></h3>
    <p>
      The following list gives an overview of all acronyms and abbreviations
      that are used throughout this paper including links to the first
      use as well as the chapter where it has occured:
    </p>
    <xsl:for-each select="//abbr|//acronym">
      <xsl:sort data-type="text" select="." />
      <xsl:apply-templates select="." mode="defIndexList" />
    </xsl:for-each>
    <!-- Alternative: with a table -->
    <!-- table width="70%" align="center">
      <tr><th width="70%">Term</th><th width="30%">Defined in...</th></tr>
      <xsl:for-each select="//dfn">
        <xsl:sort data-type="text" select="." />
        <xsl:apply-templates select="." mode="defIndex" />
      </xsl:for-each>
    </table -->
    <p />
    <br />

    <h3><a id="tablesIndex" name="tablesIndex">
      <xsl:value-of select="$sectionCountInd" />
      <xsl:text>.3 </xsl:text>
      Tables</a></h3>
    <p>
      The following table gives an overview of all tables that
      are included in this paper with a link to the table, its
      caption and a summary describing the contents of the table:
    </p>
    <table>
      <tr><th width="20%">Table</th><th width="80%">Caption / Summary</th></tr>
      <xsl:apply-templates select="//table[not(@class='noindex')]" mode="tableIndex" />
    </table>


    <h3><a id="figuresIndex" name="figuresIndex">
      <xsl:value-of select="$sectionCountInd" />
      <xsl:text>.4 </xsl:text>
      Figures</a></h3>
    <p>
      The following table gives an overview of all figures that
      are included in this paper with a link to the figure, its
      caption and a summary describing what the figure illustrates:
    </p>
    <table>
      <tr><th width="20%">Figure</th><th width="80%">Caption / Summary</th></tr>
      <xsl:apply-templates select="//srf:figure" mode="figureIndex" />
    </table>


    <!-- References -->
    <h2 class="chapter"><a id="ref" name="ref">
      <xsl:value-of select="$sectionCountRef" />
      <xsl:text> </xsl:text>
      References</a></h2>

    <table class="references">
      <xsl:variable name="bibfile" select="//srf:bibliography/@src" />
      <xsl:if test="not(document($bibfile))">
        <strong class="pending">
          Could not find or parse bibliography file
          <code><xsl:value-of select="$bibfile" /></code>
        </strong>! Please check the URI and syntax of file!
      </xsl:if>
      <xsl:apply-templates select="document($bibfile)" />
    </table>

    <!-- Page footer -->
    <div class="noprint">
      <hr />
          <table style="width:100%;">
            <tr>
              <td style="width:33%;">
                <a href="http://www.pms.informatik.uni-muenchen.de/">
                  <img alt="[PMS]" src="ext/home.gif"/>
                  Lehr- und Forschungseinheit</a>
              </td>
              <td style="width:33%;">
                <a href="http://www.informatik.uni-muenchen.de/">
                  <img alt="[Computer Science]" src="ext/home.gif"/>
                    Institut</a>
              </td>
              <td style="width:33%;">
                <a href="http://www.uni-muenchen.de/">
                  <img alt="[University of Munich]" src="ext/home.gif"/>
                  Universität</a>
              </td>
            </tr>
          </table>
          <xsl:comment>#include file="ssi/footer1.txt"</xsl:comment>
          <xsl:comment>#echo var="LAST_MODIFIED"</xsl:comment>
          <xsl:comment>#include file="ssi/footer2.txt"</xsl:comment>
    </div>
  </body>
</html>
  </xsl:template>
</xsl:stylesheet>
<!--
$Log: paperFormat.xsl,v $
Revision 1.12  2002/12/08 19:03:17  david
significantly improved readability of the stylesheet, but only in the
first part ;-)

Revision 1.11  2002/12/08 14:09:39  david
major performance improvements (processing the diploma thesis
previously took about 25 seconds, now it's only 6 seconds - this
has been achieved be replacing //element with the exact path
(e.g. /srf:article/srf:body/srf:chapter) where possible - makes code
somewhat more verbose... which may be good... and in particular,
improves performance significantly)

Furthermore, integrated CVS much better...


================
Revision : 1.10 Date : 2002/12/2 16:12:2 Author : 'david'
Description : improved VERY SIGNIFICANTLY...
e.g.: - figures
      - footnotes
================
Revision : 1.9 Date : 2002/7/23 14:11:38 Author : 'david'
Revision : 1.8 Date : 2002/3/25 9:13:40  Author : 'david'
Revision : 1.7 Date : 2002/3/11 9:23:14  Author : 'david'
================
Revision : 1.6 Date : 2002/2/22 16:44:52 Author : 'david'
Description : now using namespace and a different (bibliography-like)
              format for the "metadata"
================
Revision : 1.5 Date : 2002/2/15 15:45:39 Author : 'david'
Description :
fixed CSS to work better with Netscape 4.7;
fixed doctype definition / reference to XHTML;
support cite-tags with href for external definitions;
some simplifications and style improvements;
including external bibliography
================
Revision : 1.4 Date : 2002/2/12 19:35:15 Author : 'david'
Description :
added usage of title-attributes in dfn tags for definitions where not the
complete term is given
================
Revision : 1.3 Date : 2002/2/12 15:10:3 Author : 'david'
Description : now indices of definitions and tables also work!
================
Revision : 1.2 Date : 2002/2/9 17:2:20 Author : 'david'
Description :
adding support for cross references - here both variations are included!
================
Revision : 1.1 Date : 2002/2/9 15:36:10 Author : 'david'
Description :
Added to version control: toc is fine, cite is fine,
including the document is basically fine...
-->
