diff software/mpdl-services/mpiwg-mpdl-xml/build/classes/de/mpg/mpiwg/berlin/mpdl/xml/transform/pageArchimedes.xsl @ 23:e845310098ba

diverse Korrekturen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 27 Nov 2012 12:35:19 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/software/mpdl-services/mpiwg-mpdl-xml/build/classes/de/mpg/mpiwg/berlin/mpdl/xml/transform/pageArchimedes.xsl	Tue Nov 27 12:35:19 2012 +0100
@@ -0,0 +1,820 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xlink="http://www.w3.org/1999/xlink"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:functx="http://www.functx.com"
+  xmlns:saxon="http://saxon.sf.net/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/" 
+  xmlns:dcterms="http://purl.org/dc/terms"
+  xmlns:echo="http://www.mpiwg-berlin.mpg.de/ns/echo/1.0/" 
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:mml="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml">
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:variable name="collectionName" select="'echo'"/>
+<xsl:variable name="polluxServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="/">
+  <xsl:apply-templates mode="text"/>
+</xsl:template>
+
+<xsl:template match="text" mode="text">
+  <xsl:apply-templates mode="text"/>
+  <!--   TEI Dictionary                      -->
+  <xsl:if test="not(empty(//entry))">
+    <xsl:for-each select="//entry">
+      <xsl:sort select="form/orth"/>
+      <xsl:variable name="position" select="position()"/>
+      <span class="entry">
+        <xsl:apply-templates mode="text" select="form"/>
+        <xsl:apply-templates mode="text" select="sense"/>
+        <xsl:if test="not(empty(figure))">
+          <span class="entryDiv">
+            <span class="bf"><xsl:value-of select="'Figures: '"/></span>
+            <span class="entryDiv">
+              <xsl:for-each select="figure">
+                <xsl:variable name="href" select="graphic/@url"/>
+                <xsl:variable name="head" select="head"/>
+                <xsl:variable name="figDesc" select="string(figDesc)"/>
+                <xsl:if test="$href != ''">
+                  <div class="figure" style="margin-left:10px;">
+                    <a href="{$href}"><img alt="Figure: {$figDesc}" src="{$href}" width="200" height="200"/></a>
+                    <br/>
+                    <xsl:value-of select="'[Figure]: '"/><xsl:value-of select="$head"/>
+                  </div>
+                </xsl:if>
+              </xsl:for-each>
+            </span>
+          </span>
+        </xsl:if>
+        <xsl:if test="not(empty(xr))">
+          <span class="entryDiv">
+            <span class="bf"><xsl:value-of select="'References: '"/></span>
+            <span class="entryDiv">
+              <xsl:for-each select="xr/ref">
+                <li><xsl:apply-templates mode="text" select="."/></li>
+              </xsl:for-each>
+            </span>
+          </span>
+        </xsl:if>
+      </span>
+    </xsl:for-each>  
+  </xsl:if>
+  <!--   Notes                      -->
+  <!--
+  <xsl:variable name="countEmptyPlaces" select="count($notes/note[empty(@place)])"/>
+  <xsl:variable name="countBottomPlaces">
+    <xsl:choose>
+      <xsl:when test="$collectionName = 'archimedes' or $collectionName = 'tei'">
+        <xsl:value-of select="count($notes/note[contains(@place, 'bottom')])"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="count($notes/note[contains(@position, 'bottom') or empty(string(@position))])"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:if test="($collectionName = 'archimedes' or $collectionName = 'tei') and count($notes/*) > 0">
+    <div>
+      <xsl:choose>
+        <xsl:when test="$countBottomPlaces > 0 or $countEmptyPlaces > 0">
+          <hr class="notesBottom"/>
+        </xsl:when>
+        <xsl:otherwise></xsl:otherwise>
+      </xsl:choose>
+      <xsl:for-each select="$notes/note">
+        <xsl:variable name="notePos" select="position()"/>
+        <xsl:variable name="place" select="@place"/>
+        <xsl:variable name="label" select="$notePos"/>
+        <xsl:variable name="uid" select="@uid"/>
+        <xsl:variable name="modificationDate" select="@modificationDate"/>
+        <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/>
+        <xsl:choose>
+          <xsl:when test="$place = '' or empty($place) or $place = 'bottom'">
+            <p>
+              <a>
+                <xsl:attribute name="name"><xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/></xsl:attribute>
+                <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', 'note-', $pageNumber, '-', $label, 'ref')"/></xsl:attribute>
+                <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+                <xsl:value-of select="concat('note-', $pageNumber, '-', $label)"/>
+              </a>
+              <xsl:value-of select="': '"/>
+              <xsl:choose>
+                <xsl:when test="$uid = '' or empty($uid)">
+                  <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
+                </xsl:when>
+                <xsl:otherwise>
+                  <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
+                  <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
+                </xsl:otherwise>
+              </xsl:choose>
+            </p>
+          </xsl:when>
+          <xsl:otherwise></xsl:otherwise>
+        </xsl:choose>
+      </xsl:for-each>
+    </div>
+  </xsl:if>
+  <xsl:if test="$collectionName = 'echo' and count($notes/*) > 0">
+    <div>
+      <xsl:choose>
+        <xsl:when test="$countBottomPlaces > 0 or $countEmptyPlaces > 0">
+          <hr class="notesBottom"/>
+        </xsl:when>
+        <xsl:otherwise></xsl:otherwise>
+      </xsl:choose>
+      <xsl:for-each select="$notes/echo:note">
+        <xsl:variable name="label" select="string(@xlink:label)"/>
+        <xsl:variable name="place" select="@position"/>
+        <xsl:variable name="uid" select="@uid"/>
+        <xsl:variable name="modificationDate" select="@modificationDate"/>
+        <xsl:variable name="noteWithoutNamespace" select="mpdl-util:copyWithoutNamespace(.)"/>
+        <xsl:choose>
+          <xsl:when test="$place = '' or empty($place) or $place = 'bottom'">
+            <p>
+              <a>
+                <xsl:attribute name="name"><xsl:value-of select="$label"/></xsl:attribute>
+                <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $label, 'ref')"/></xsl:attribute>
+                <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+                <xsl:value-of select="$label"/>
+              </a>
+              <xsl:value-of select="': '"/>
+              <xsl:choose>
+                <xsl:when test="$uid = '' or empty($uid)">
+                  <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
+                </xsl:when>
+                <xsl:otherwise>
+                  <span class="note"><xsl:apply-templates select="$noteWithoutNamespace/node()" mode="text"/></span>
+                  <xsl:value-of select="concat(' [external note, ', $uid, ', ', $modificationDate, ']')"/>
+                </xsl:otherwise>
+              </xsl:choose>
+            </p>
+          </xsl:when>
+          <xsl:otherwise></xsl:otherwise>
+         </xsl:choose>
+      </xsl:for-each>
+    </div>
+  </xsl:if>
+  -->
+</xsl:template>
+
+<xsl:template match="head" mode="text">
+  <xsl:variable name="class">
+    <xsl:value-of select="'head bf'"/>
+  </xsl:variable>
+  <p>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+      <xsl:apply-templates mode="text"/>
+    </span>
+  </p>
+</xsl:template>
+
+<!-- TEI: segmentation   -->
+<xsl:template match="seg" mode="text">
+  <xsl:choose>
+    <xsl:when test="@rend = 'highlight'">
+      <span class="seg highlight"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="@rend = 'highlightPoint'">
+      <span class="seg highlightPoint"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="seg"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: choice   -->
+<xsl:template match="choice" mode="text">
+  <xsl:if test="not(empty(orig))">
+    <xsl:apply-templates select="orig" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(abbr))">
+    <xsl:apply-templates select="abbr" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(am))">
+    <xsl:apply-templates select="am" mode="text"/>
+  </xsl:if>
+  <xsl:if test="not(empty(sic))">
+    <xsl:apply-templates select="sic" mode="text"/>
+  </xsl:if>
+</xsl:template>
+
+<!-- TEI: hi (highlighted)  -->
+<xsl:template match="hi" mode="text">
+  <xsl:choose>
+    <xsl:when test="@rend = 'initial'">
+      <span class="dc-unmodified"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="@rend = 'bold'">
+      <span class="bf"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: name (of type: place, person, ...)   -->
+<xsl:template match="name" mode="text">
+  <xsl:choose>
+    <xsl:when test="@type = 'place'">
+      <span class="place" title="Place"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="@type = 'person'">
+      <span class="person" title="Person"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="@type = 'org'">
+      <span class="organization" title="Organization"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: place, person, ...)   -->
+<xsl:template match="placeName" mode="text">
+  <span class="place" title="Place: {@type}"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+<xsl:template match="persName" mode="text">
+  <span class="person" title="Person"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+<!-- TEI: term    -->
+<xsl:template match="term" mode="text">
+  <span class="term" title="Terminology entry"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+<!-- TEI: line    -->
+<xsl:template match="lg" mode="text">
+  <div class="lg"><xsl:apply-templates mode="text"/></div>
+</xsl:template>
+
+<xsl:template match="l" mode="text">
+  <span class="l"><xsl:apply-templates mode="text"/></span><br/>
+</xsl:template>
+
+<!-- TEI: reference    -->
+<xsl:template match="ref" mode="text">
+  <span class="ref">
+    <xsl:if test="not(empty(@target))">
+      <a>
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </a>
+    </xsl:if>
+    <xsl:if test="empty(@target)">
+      <xsl:apply-templates mode="text"/>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- TEI: table    -->
+<xsl:template match="table" mode="text">
+  <table>
+    <xsl:if test="not(empty(head))">
+      <caption align="top"><xsl:apply-templates mode="text" select="head"/></caption>
+    </xsl:if>
+    <xsl:apply-templates mode="text" select="row"/>
+  </table>
+</xsl:template>
+
+<xsl:template match="row" mode="text">
+  <xsl:choose>
+    <xsl:when test="@role = 'label'">
+      <tr style="font-weight:bold;"><xsl:apply-templates mode="text"/></tr>
+    </xsl:when>
+    <xsl:when test="@role = 'data' or empty(@role)">
+      <tr><xsl:apply-templates mode="text"/></tr>
+    </xsl:when>
+    <xsl:otherwise>
+      <tr><xsl:apply-templates mode="text"/></tr>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="cell" mode="text">
+  <xsl:choose>
+    <xsl:when test="@role = 'label' and empty(@cols)">
+      <td style="font-weight:bold;"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="@role = 'label' and not(empty(@cols))">
+      <td colspan="{@cols}" style="font-weight:bold;"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="(@role = 'data' or empty(@role)) and empty(@cols)">
+      <td><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:when test="(@role = 'data' or empty(@role)) and not(empty(@cols))">
+      <td colspan="{@cols}"><xsl:apply-templates mode="text"/></td>
+    </xsl:when>
+    <xsl:otherwise>
+      <td><xsl:apply-templates mode="text"/></td>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- TEI: dictionary    -->
+<xsl:template match="entry" mode="text">
+  <!-- empty: handled in text tag    -->
+</xsl:template>
+
+<xsl:template match="form" mode="text">
+  <span class="form">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="orth" mode="text">
+  <span class="orth">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="sense" mode="text">
+  <span class="entryDiv"><xsl:apply-templates mode="text" select="def"/></span>
+  <span class="entryDiv"><xsl:apply-templates mode="text" select="etym"/></span>
+</xsl:template>
+
+<xsl:template match="def" mode="text">
+  <span class="def">
+    <span class="bf"><xsl:value-of select="'Definition: '"/></span>
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="mentioned" mode="text">
+  <span class="mentioned">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="etym" mode="text">
+  <span class="etym">
+    <span class="bf"><xsl:value-of select="'Etymology: '"/></span>
+    <span class="entryDiv">
+      <xsl:for-each select="cit">
+        <li><xsl:value-of select="quote"/><xsl:value-of select="' ('"/><xsl:value-of select="def"/><xsl:value-of select="')'"/></li>
+      </xsl:for-each>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="cit" mode="text">
+  <span class="cit">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<!-- TEI: MathML    -->
+<xsl:template match="math:*" mode="text">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
+<!-- TEI: SVG    -->
+<xsl:template match="svg:*" mode="text">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="div" mode="text">
+  <xsl:variable name="type" select="@type"/>
+  <xsl:variable name="level" select="@level"/>
+  <xsl:variable name="style" select="@style"/>
+  <xsl:variable name="border" select="@border"/>
+  <xsl:variable name="width" select="@width"/>
+  <xsl:variable name="note" select="note"/>
+  <xsl:variable name="figure" select="figure"/>
+  <xsl:variable name="floatClassValue">
+    <xsl:choose>
+      <xsl:when test="not(empty($note))"><xsl:value-of select="''"/></xsl:when>
+      <xsl:when test="not(empty($figure))"><xsl:value-of select="''"/></xsl:when>
+      <xsl:when test="$type = 'float'"><xsl:value-of select="'float left'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="'float left'"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="levelClassValue">
+    <xsl:choose>
+      <xsl:when test="not(empty($note))"><xsl:value-of select="''"/></xsl:when>
+      <xsl:when test="$level = '1'"><xsl:value-of select="'level one'"/></xsl:when>
+      <xsl:when test="$level = '2'"><xsl:value-of select="'level two'"/></xsl:when>
+      <xsl:when test="$level = '3'"><xsl:value-of select="'level three'"/></xsl:when>
+      <xsl:when test="$level = '4'"><xsl:value-of select="'level four'"/></xsl:when>
+      <xsl:when test="$level = '5'"><xsl:value-of select="'level five'"/></xsl:when>
+      <xsl:when test="$level = '6'"><xsl:value-of select="'level six'"/></xsl:when>
+      <xsl:when test="$level = '7'"><xsl:value-of select="'level seven'"/></xsl:when>
+      <xsl:when test="$level = '8'"><xsl:value-of select="'level eight'"/></xsl:when>
+      <xsl:when test="$level = '9'"><xsl:value-of select="'level nine'"/></xsl:when>
+      <xsl:when test="empty($level)"><xsl:value-of select="''"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="'level n'"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <div>
+    <xsl:if test="not(empty($style))"><xsl:attribute name="style"><xsl:value-of select="$style"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="concat($floatClassValue, ' ', $levelClassValue)"/></xsl:attribute>
+    <xsl:apply-templates mode="text"/>
+  </div>
+</xsl:template>
+
+<xsl:template match="p" mode="text">
+  <xsl:variable name="style" select="@style"/>
+  <xsl:variable name="class">
+    <xsl:value-of select="'p'"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="not(empty($style))">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+          <xsl:apply-templates mode="text"/>
+        </span>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </div>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="lb|br" mode="text">
+  <br></br><xsl:apply-templates mode="text"/>
+</xsl:template>
+
+<xsl:template match="cb" mode="text">
+  <br/><xsl:apply-templates mode="text"/>
+</xsl:template>
+
+<xsl:template match="expan" mode="text">
+  <xsl:choose>
+    <xsl:when test="not(empty(@style))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('expan ', @style)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="expan"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="note" mode="text">
+  <!--
+  <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
+  <xsl:variable name="place">
+    <xsl:choose>
+      <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="@place"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="@position"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="notePos" select="count(preceding::note[. >> $topPB]) + 1"/>
+  <xsl:variable name="href" select="concat('note-', $pageNumber, '-', $notePos)"/>
+  <xsl:choose>
+    <xsl:when test="$collectionName = 'archimedes'">
+      <a>
+        <xsl:attribute name="name"><xsl:value-of select="concat($href, 'ref')"/></xsl:attribute>
+        <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $href)"/></xsl:attribute>
+        <xsl:attribute name="class"><xsl:value-of select="'noteRef super'"/></xsl:attribute>
+        <xsl:value-of select="$href"/>
+      </a>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and not($hasLabel) and not(empty($place))">
+      <span>    
+        <xsl:attribute name="class"><xsl:value-of select="concat('note margin ', $place)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and not($hasLabel)">
+      <p>
+        <xsl:value-of select="'[Note]: '"/>
+        <span class="note"><xsl:apply-templates mode="text"/></span>
+      </p>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and $hasLabel"></xsl:when>
+    <xsl:when test="$collectionName = 'tei'">
+      <xsl:choose>
+        <xsl:when test="contains($place, 'margin')">
+          <span>    
+            <xsl:attribute name="class"><xsl:value-of select="concat('note ', $place)"/></xsl:attribute>
+            <xsl:apply-templates mode="text"/>
+          </span>
+        </xsl:when>
+        <xsl:otherwise>
+          <a>
+            <xsl:attribute name="name"><xsl:value-of select="concat($href, 'ref')"/></xsl:attribute>
+            <xsl:attribute name="href"><xsl:value-of select="concat(urlBase, '#', $href)"/></xsl:attribute>
+            <xsl:attribute name="class"><xsl:value-of select="'noteRef super'"/></xsl:attribute>
+            <xsl:value-of select="$href"/>
+          </a>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="note"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+  -->
+</xsl:template>
+
+<xsl:template match="emph" mode="text">
+  <xsl:variable name="style" select="@style"/>
+  <xsl:variable name="styleWithoutSC" select="replace($style, 'sc ', '')"/>
+  <xsl:variable name="text" select="string-join(., '')"/>
+  <xsl:variable name="length" select="string-length($text)"/>
+  <xsl:variable name="firstChar" select="substring($text, 1, 1)"/>
+  <xsl:variable name="first2Chars" select="substring($text, 1, 2)"/>
+  <xsl:variable name="restChars" select="substring($text, 2, $length)"/>
+  <xsl:variable name="first2CharsAreUppercase" select="upper-case($first2Chars) = $first2Chars"/>
+  <!-- an emph as first element in p and also an emph in s in p is recognized  --> 
+  <xsl:variable name="isFirstElementInP" select="(not(empty(./parent::*/parent::p)) and (empty(./parent::*/preceding-sibling::node()) and empty(./preceding-sibling::node()))) or (not(empty(./parent::p)) and empty(./preceding-sibling::node()))"/>
+  <xsl:variable name="rest">
+    <xsl:choose>
+      <xsl:when test="$length &lt; 2 or empty($length)"><xsl:value-of select="''"/></xsl:when>
+      <xsl:otherwise>
+        <xsl:choose>
+          <xsl:when test="not(empty(w))">
+            <a class="textPollux" href="{$polluxServiceName}?query={w/@form}&amp;queryDisplay={$text}&amp;language={w/@lang}&amp;outputFormat=html&amp;outputType=morphCompact&amp;outputType=dictFull"><xsl:value-of select="$restChars"/></a>
+          </xsl:when>
+          <xsl:otherwise><xsl:value-of select="$restChars"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$collectionName = 'echo' and not(contains($style, 'sc'))">
+      <span class="{$style}"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and $style = 'sc' and $length = 1">
+      <span class="sc"><xsl:value-of select="$firstChar"/></span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and $style = 'sc' and not($isFirstElementInP)">
+      <span class="sc"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <!-- special case (see text() node below): first char dc, rest sc  -->
+    <xsl:when test="$collectionName = 'echo' and $style = 'dc sc logic' and $first2CharsAreUppercase">
+      <span class="dc"><xsl:value-of select="$firstChar"/></span><span class="sc"><xsl:sequence select="$rest"/></span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and $style = 'sc' and $first2CharsAreUppercase">
+      <span class="dc"><xsl:value-of select="$firstChar"/></span><span class="sc"><xsl:sequence select="$rest"/></span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and contains($style, 'sc') and $first2CharsAreUppercase">
+      <span class="dc"><span class="{$styleWithoutSC}"><xsl:value-of select="$firstChar"/></span></span><span class="sc"><span class="{$styleWithoutSC}"><xsl:sequence select="$rest"/></span></span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and $style = 'sc' and not($first2CharsAreUppercase)">
+      <span class="sc"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'echo' and contains($style, 'sc') and not($first2CharsAreUppercase)">
+      <span class="sc"><span class="{$styleWithoutSC}"><xsl:apply-templates mode="text"/></span></span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'archimedes' and $style != ''">
+      <span class="{$style}"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="$collectionName = 'archimedes' and $style = ''">
+      <span class="emph"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="$style != ''">
+      <span class="{$style}"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="emph"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="foreign" mode="text">
+  <xsl:variable name="lang" select="@lang"/>
+  <xsl:variable name="xmllang" select="@xml:lang"/>
+  <xsl:variable name="language">
+    <xsl:choose>
+      <xsl:when test="not(empty($xmllang))"><xsl:value-of select="$xmllang"/></xsl:when>
+      <xsl:when test="not(empty($lang))"><xsl:value-of select="$lang"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:attribute name="class"><xsl:value-of select="concat('foreign ', $language)"/></xsl:attribute>
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="q" mode="text">
+  <xsl:choose>
+    <xsl:when test="not(empty(@style))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('q ', @style)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="q"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="quote" mode="text">
+  <xsl:choose>
+    <xsl:when test="not(empty(@style))">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('quote ', @style)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <div class="quote"><xsl:apply-templates mode="text"/></div>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="blockquote" mode="text">
+  <xsl:choose>
+    <xsl:when test="not(empty(@style))">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('blockquote ', @style)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <div class="blockquote"><xsl:apply-templates mode="text"/></div>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="set-off" mode="text">
+  <xsl:choose>
+    <xsl:when test="not(empty(@style))">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('set-off ', @style)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <div class="set-off"><xsl:apply-templates mode="text"/></div>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="reg" mode="text">
+  <xsl:choose>
+    <xsl:when test="not(empty(@style))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('reg ', @style)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="reg"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="var" mode="text">
+  <xsl:choose>
+    <xsl:when test="not(empty(@style))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('reg ', @type, ' ', @style)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="var">
+        <xsl:attribute name="class"><xsl:value-of select="concat('var ', @type)"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="num" mode="text">
+  <xsl:choose>
+    <xsl:when test="not(empty(@style))">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="@style"/></xsl:attribute>
+          <xsl:apply-templates mode="text"/>
+        </span>
+      </span>
+    </xsl:when>
+    <xsl:otherwise>
+      <span class="num"><xsl:apply-templates mode="text"/></span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="gap" mode="text">
+  <xsl:variable name="extent" select="@extent"/>
+  <xsl:variable name="count">
+    <xsl:choose>
+      <xsl:when test="empty($extent)"><xsl:value-of select="number(3)"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="number($extent)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="gapChars" select="'...'"/>
+  <xsl:value-of select="concat('[', $gapChars, ']')"/><xsl:apply-templates mode="text"/>
+</xsl:template>
+
+<xsl:template match="anchor" mode="text">
+  <a><xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute><xsl:apply-templates mode="text"/></a>
+</xsl:template>
+
+<!-- GIS Elements   -->
+<xsl:template match="place" mode="text">
+  <span class="place">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="time" mode="text">
+  <span class="time">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="person" mode="text">
+  <span class="person">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="event" mode="text">
+  <span class="event">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<!-- XHTML: remove the xhtml namespace   -->
+<xsl:template match="xhtml:*" mode="text">
+  <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
+  <xsl:variable name="isTable" select="name() = 'table'"/>
+  <xsl:choose>
+    <xsl:when test="(not($hasLabel)) or ($isTable and $hasLabel)">
+      <xsl:element name="{name()}" namespace="">
+        <xsl:copy-of select="@*"/>
+        <xsl:apply-templates mode="text"/>
+      </xsl:element>
+    </xsl:when>
+    <xsl:otherwise></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="figure" mode="text">
+  <span class="figure">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="caption" mode="text">
+  <span class="figureCaption"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+<xsl:template match="description" mode="text">
+  <span class="figureDescription"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+<xsl:template match="handwritten" mode="text">
+  <span class="handwritten"><xsl:apply-templates mode="text"/></span>
+</xsl:template>
+
+
+<!-- words                            -->
+<xsl:template match="w" mode="text">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(@form)"/>
+  <xsl:variable name="displayWord"><xsl:apply-templates mode="text"/></xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWord)"/>
+  <a class="textPollux">
+    <xsl:attribute name="href"><xsl:value-of select="concat($polluxServiceName, '?query=', $form, '&amp;queryDisplay=', $displayWordUrlEncoded, '&amp;language=', $wordLanguage, '&amp;outputFormat=html', '&amp;outputType=morphCompact&amp;outputType=dictFull')"/></xsl:attribute>
+    <xsl:sequence select="$displayWord"/>
+  </a>
+</xsl:template>
+
+<xsl:template match="s" mode="text">
+  <span class="s">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="text()" mode="text">
+  <xsl:value-of select="."/>
+</xsl:template>
+
+</xsl:stylesheet>