<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Style sheet that builds a nice thesis from the "draft"-XHTML file!
Author: Holger (David) Wagner, 2002-02-09
-->
<!-- DOCTYPE stylesheet [ -->
<!-- ENTITY space "<xsl:text> </xsl:text>" -->
<!-- ENTITY auml "ä">
<!ENTITY ouml "ö">
<!ENTITY uuml "ü">
<!ENTITY Uuml "Ü">
<!ENTITY Ouml "Ö">
<!ENTITY Auml "Ä">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
] -->
<xsl:stylesheet 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">
<xsl:output method="html"
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" />
<!-- The HTML-PMS-Paper frame is at the end of the stylesheet for simplicity -->
<!-- build the Table of Contents -->
<xsl:template match="srf:appendix|srf:section|srf:subsection|srf:subsubsection" mode="toc">
<xsl:variable name="tocID" select="@id" />
<xsl:variable name="headingTag">
<xsl:choose>
<xsl:when test="local-name() = 'section' or local-name() = 'appendix'">h2</xsl:when>
<xsl:when test="local-name() = 'subsection'">h3</xsl:when>
<xsl:when test="local-name() = 'subsubsection'">h4</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$headingTag}">
<a href="#{$tocID}">
<xsl:number level="multiple"
count="srf:section|srf:subsection|srf:subsubsection"
format="1.1.1 " />
<xsl:value-of select="@title" />
</a>
</xsl:element>
<xsl:apply-templates select="srf:section|srf:subsection|srf:subsubsection" mode="toc" />
</xsl:template>
<!-- Format the actual contents, section by section -->
<xsl:template match="srf:appendix|srf:section|srf:subsection|srf:subsubsection">
<xsl:variable name="tocID" select="@id" />
<xsl:variable name="headingTag">
<xsl:choose>
<xsl:when test="local-name() = 'section' or local-name() = 'appendix'">h2</xsl:when>
<xsl:when test="local-name() = 'subsection'">h3</xsl:when>
<xsl:when test="local-name() = 'subsubsection'">h4</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:element name="{$headingTag}">
<xsl:if test="$headingTag = 'h2'">
<xsl:attribute name="class">section</xsl:attribute>
</xsl:if>
<a id="{$tocID}" name="{$tocID}">
<xsl:number level="multiple"
count="srf:section|srf:subsection|srf:subsubsection"
format="1.1.1 " />
<xsl:value-of select="@title" />
</a>
</xsl:element>
<small><a href="#toc">[toc]</a></small>
<xsl:apply-templates select="br|p|q|table|ul|ol|blockquote|srf:section|srf:subsection|srf:subsubsection" />
</xsl:template>
<!-- Copy most... -->
<xsl:template match="@*|br|p|a|em|strong|ul|li|tr|th|td|abbr|acronym">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!-- quotes -->
<xsl:template match="q">
“<xsl:apply-templates select="@*|node()" />” (<a href="#@cite"><cite>[<xsl:value-of select="@cite" />]</cite></a>)
<!-- xsl:copy-of select="." / -->
</xsl:template>
<xsl:template match="blockquote">
<blockquote cite="@cite">
<p>
“<xsl:apply-templates select="./p/node()" />” (<a href="#@cite"><cite>[<xsl:value-of select="@cite" />]</cite></a>)
</p>
</blockquote>
</xsl:template>
<!-- useful especially for printing! -->
<!-- acronyms and abbreviations -->
<xsl:template match="acronym | abbr">
<xsl:copy-of select="." />
<xsl:text> </xsl:text><em>[<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">
<xsl:text> </xsl:text><em>[<xsl:value-of select="@href" />]</em>
</xsl:if>
</xsl:template>
<!-- fix cross-references -->
<xsl:template match="a[@class='crossRef']">
<xsl:variable name="target" select="@href" />
<xsl:apply-templates select="//srf:section[@id=$target]|//srf:subsection[@id=$target]|//srf:subsubsection[@id=$target]"
mode="crossRefFull" />
</xsl:template>
<!-- used by "fix cross-references" and index builders -->
<xsl:template match="srf:section|srf:subsection|srf:subsubsection" mode="crossRefFull">
<xsl:variable name="target" select="@id" />
<xsl:variable name="title" select="@title" />
<a href="#{$target}">
section <xsl:text> </xsl:text>
<em class="crossRef">
<xsl:apply-templates select="//srf:section[@id=$target]|//srf:subsection[@id=$target]|//srf:subsubsection[@id=$target]"
mode="crossRefNum" />
<!-- xsl:value-of select="$title" / -->
</em>
</a>
</xsl:template>
<xsl:template match="srf:section|srf:subsection|srf:subsubsection" mode="crossRefNum">
<xsl:number level="multiple"
count="srf:section|srf:subsection|srf:subsubsection"
format="1.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">
<em class="dfn">
<xsl:element name="a">
<xsl:attribute name="id">Def_<xsl:value-of select="@id" /></xsl:attribute>
<xsl:attribute name="name">Def_<xsl:value-of select="@id" /></xsl:attribute>
<xsl:if test="@href">
<xsl:attribute name="href"><xsl:value-of select="@href" /></xsl:attribute>
</xsl:if>
<!-- a id="Def_{@id}" name="Def_{@id}" -->
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates />
</xsl:copy>
<!-- /a -->
</xsl:element>
</em>
</xsl:template>
<!-- build index of definitions (inside a table) -->
<xsl:template match="dfn" mode="defIndexTable">
<xsl:variable name="id" select="@id" />
<xsl:variable name="sectionID">
<xsl:choose>
<xsl:when test="ancestor::srf:subsubsection/@id">
<xsl:value-of select="ancestor::srf:subsubsection/@id" />
</xsl:when>
<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:choose>
</xsl:variable>
<tr class="terms">
<td class="terms">
<a href="#Def_{$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:section[@id=$sectionID]|//srf:subsection[@id=$sectionID]|//srf:subsubsection[@id=$sectionID]"
mode="crossRefFull" />
</td>
</tr>
</xsl:template>
<!-- ALTERNATIVE: build index of definitions (as a list) -->
<xsl:template match="dfn" mode="defIndexList">
<xsl:variable name="id" select="@id" />
<xsl:variable name="sectionID">
<xsl:choose>
<xsl:when test="ancestor::srf:subsubsection/@id">
<xsl:value-of select="ancestor::srf:subsubsection/@id" />
</xsl:when>
<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:choose>
</xsl:variable>
<span class="terms">
<a href="#Def_{$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><xsl:text> (</xsl:text>
<xsl:apply-templates select="//srf:section[@id=$sectionID]|//srf:subsection[@id=$sectionID]|//srf:subsubsection[@id=$sectionID]"
mode="crossRefFull" />)</span><br />
</xsl:template>
<!-- enumerate tables -->
<xsl:template match="table">
<p><a id="Table_{@id}" name="Table_{@id}"><xsl:text> </xsl:text></a></p>
<xsl:copy>
<xsl:copy-of select="@*" />
<caption style="caption-side:bottom;">
<strong>
<xsl:apply-templates select="self::table" mode="tableNumber" />:
<xsl:value-of select="caption/text()" />
</strong>
</caption>
<xsl:apply-templates select="tr" />
</xsl:copy>
<p />
</xsl:template>
<xsl:template match="table" mode="tableNumber">
Table <xsl:text> </xsl:text>
<xsl:number level="multiple"
count="srf:section|srf:subsection|srf:subsubsection"
format="1.1.1" />
<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>
<