changeset 13:469d927b9ca7

diverse Fehlerbehebungen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 19 Apr 2011 16:51:59 +0200
parents fba5577e49d9
children 5df60f24e997
files software/eXist/webapp/mpdl/doc/doc-operation-exist.xql software/eXist/webapp/mpdl/images/link.png software/eXist/webapp/mpdl/images/linkback.png software/eXist/webapp/mpdl/images/linkext.png software/eXist/webapp/mpdl/images/linkto.png software/eXist/webapp/mpdl/images/slime_logo.png software/eXist/webapp/mpdl/info.xql software/eXist/webapp/mpdl/interface/lt/wordInfo.xql software/eXist/webapp/mpdl/interface/page-fragment.xql software/eXist/webapp/mpdl/page-query-result.xql software/eXist/webapp/mpdl/presentation/functions-mpdl.xsl software/eXist/webapp/mpdl/presentation/insertExternalElements.xsl software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl software/eXist/webapp/mpdl/presentation/pageHtml.css software/eXist/webapp/mpdl/presentation/pageHtml.xsl
diffstat 15 files changed, 688 insertions(+), 163 deletions(-) [+]
line wrap: on
line diff
--- a/software/eXist/webapp/mpdl/doc/doc-operation-exist.xql	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/doc/doc-operation-exist.xql	Tue Apr 19 16:51:59 2011 +0200
@@ -36,7 +36,7 @@
     <!--
     function DocumentSelection() {
       var existIdentifier = document.docBaseList.doc[document.docBaseList.doc.selectedIndex].value;
-      var existLink = "http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/page-query-result.xql?document=".concat(existIdentifier);
+      var existLink = "http://" + window.location.host + "/mpdl/page-query-result.xql?document=" + existIdentifier;
       var existIdentifierSplit = existIdentifier.split("/");
       var docBase = existIdentifierSplit[1];
       var language = existIdentifierSplit[2];
Binary file software/eXist/webapp/mpdl/images/link.png has changed
Binary file software/eXist/webapp/mpdl/images/linkback.png has changed
Binary file software/eXist/webapp/mpdl/images/linkext.png has changed
Binary file software/eXist/webapp/mpdl/images/linkto.png has changed
Binary file software/eXist/webapp/mpdl/images/slime_logo.png has changed
--- a/software/eXist/webapp/mpdl/info.xql	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/info.xql	Tue Apr 19 16:51:59 2011 +0200
@@ -47,7 +47,7 @@
   else if ($info = 'pollux')
   then (<p>MPDL <a href="http://archimedes.fas.harvard.edu/pollux">Pollux</a> service.</p>, <p>Following dictionaries are supported</p>, <ul><li>Autenrieth, a Homeric lexicon (10158 entries)</li><li>Baretti, a dictionary of the English and Italian languages (53555 entries)</li><li>Bonitz, index Aristotelicus (14648 entries)</li><li>Cooper, Thesaurus Linguae Romanae et Brittanicae (33124 entries)</li><li>Florio, a worlde of wordes, or most copious, dictionarie in Italian and English (70091 entries)</li><li>Lewis and Short, Latin dictionary (53500 entries)</li><li>Liddell-Scott-Jones, a Greek-English lexicon (112631 entries)</li><li>Salmoné, an advanced learner's Arabic-English dictionary (6360 entries)</li><li>Webster's revised unabridged dictionary - 1913 (111733 entries)</li></ul>)
   else if ($info = 'wordInfo')
-  then (<p><b>Morphology information</b>: MPDL <a href="http://archimedes.fas.harvard.edu/cgi-bin/donatus">Donatus</a> and <a href="http://snowball.tartarus.org/">Snowball</a>.</p>, <p>Following morphological data is used and provided</p>, <ul><li>Perseus<ul><li>arabic: 97.249 forms</li><li>greek: 1.020.846 forms</li><li>latin: 710.620 forms</li></ul></li><li>Celex<ul><li>dutch: 381.275 forms and 124.136 lemmas</li><li>english: 160.595 forms and 52.447 lemmas</li><li>german: 365.530 forms and 51.728 lemmas</li></ul></li><li>Lexique<ul><li>french: 306.795 forms</li></ul></li></ul>, <p><b>Dictionary information:</b> MPDL <a href="http://archimedes.fas.harvard.edu/pollux">Pollux</a></p>, <p>Following internal dictionaries are provided</p>, <ul><li>Autenrieth, a Homeric lexicon (10158 entries)</li><li>Baretti, a dictionary of the English and Italian languages (53555 entries)</li><li>Bonitz, index Aristotelicus (14648 entries)</li><li>Cooper, Thesaurus Linguae Romanae et Brittanicae (33124 entries)</li><li>Florio, a worlde of wordes, or most copious, dictionarie in Italian and English (70091 entries)</li><li>Lewis and Short, Latin dictionary (53500 entries)</li><li>Liddell-Scott-Jones, a Greek-English lexicon (112631 entries)</li><li>Salmoné, an advanced learner's Arabic-English dictionary (6360 entries)</li><li>Webster's revised unabridged dictionary - 1913 (111733 entries)</li></ul>, <p>Following external dictionaries are provided</p>, <ul><li>Deutsches Wörterbuch der deutschen Sprache</li><li>William J. Slater, Lexicon to Pindar</li><li>The ARTFL project: Dictionnaires d'autrefois: French dictionaries of the 17th, 18th, 19th and 20th centuries</li><li>The ARTFL project: French - English dictionary</li><li>Charlton T. Lewis, an Elementary Latin Dictionary</li><li>Wiktionary: WikiWoordenboek</li><li>Lin Yutang</li></ul>, <p><b>Wikipedia information:</b> MPDL Wiki</p>, <p>Links to following Wikipedia servers are provided</p>, <ul><li>ar.wikipedia.org</li><li>de.wikipedia.org</li><li>el.wikipedia.org</li><li>en.wikipedia.org</li><li>fr.wikipedia.org</li><li>it.wikipedia.org</li><li>la.wikipedia.org</li><li>nl.wikipedia.org</li><li>zh.wikipedia.org</li></ul>, <p><b>Place information</b></p>, <p>Place links in Echo texts are supported. Place dictionaries are not yet implemented</p>)
+  then (<p><b>Morphology information</b>: MPDL <a href="http://archimedes.fas.harvard.edu/cgi-bin/donatus">Donatus</a>.</p>, <p>Following morphological data is used and provided</p>, <ul><li>Perseus<ul><li>arabic: 97.249 forms</li><li>greek: 1.020.846 forms</li><li>latin: 710.620 forms</li></ul></li><li>Celex<ul><li>dutch: 381.275 forms and 124.136 lemmas</li><li>english: 160.595 forms and 52.447 lemmas</li><li>german: 365.530 forms and 51.728 lemmas</li></ul></li><li>Lexique<ul><li>french: 306.795 forms</li></ul></li></ul>, <p><b>Dictionary information:</b> MPDL <a href="http://archimedes.fas.harvard.edu/pollux">Pollux</a></p>, <p>Following internal dictionaries are provided</p>, <ul><li>Autenrieth, a Homeric lexicon (10158 entries)</li><li>Baretti, a dictionary of the English and Italian languages (53555 entries)</li><li>Bonitz, index Aristotelicus (14648 entries)</li><li>Cooper, Thesaurus Linguae Romanae et Brittanicae (33124 entries)</li><li>Florio, a worlde of wordes, or most copious, dictionarie in Italian and English (70091 entries)</li><li>Lewis and Short, Latin dictionary (53500 entries)</li><li>Liddell-Scott-Jones, a Greek-English lexicon (112631 entries)</li><li>Salmoné, an advanced learner's Arabic-English dictionary (6360 entries)</li><li>Webster's revised unabridged dictionary - 1913 (111733 entries)</li></ul>, <p>Following external dictionaries are provided</p>, <ul><li>Deutsches Wörterbuch der deutschen Sprache</li><li>William J. Slater, Lexicon to Pindar</li><li>The ARTFL project: Dictionnaires d'autrefois: French dictionaries of the 17th, 18th, 19th and 20th centuries</li><li>The ARTFL project: French - English dictionary</li><li>Charlton T. Lewis, an Elementary Latin Dictionary</li><li>Wiktionary: WikiWoordenboek</li><li>Lin Yutan: humanum.arts.cuhk.edu.hk/cgi-bin/agrep-lindict</li><li>Chinese Wiktionary: en.wiktionary.org/wiki</li><li>Chinese Text Project: ctext.org/dictionary.pl</li><li>Unicode: www.unicode.org/cgi-bin/GetUnihanData.pl</li></ul>, <p><b>Wikipedia information:</b> MPDL Wiki (optional by URL parameter: type=all)</p>, <p>Links to following Wikipedia servers are provided</p>, <ul><li>ar.wikipedia.org</li><li>de.wikipedia.org</li><li>el.wikipedia.org</li><li>en.wikipedia.org</li><li>fr.wikipedia.org</li><li>it.wikipedia.org</li><li>la.wikipedia.org</li><li>nl.wikipedia.org</li><li>zh.wikipedia.org</li></ul>, <p><b>Place information</b></p>, <p>Place links in Echo texts. </p>)
   else if ($info = 'donatus')
   then (<p>MPDL <a href="http://archimedes.fas.harvard.edu/cgi-bin/donatus">Donatus</a> and <a href="http://snowball.tartarus.org/">Snowball</a> service.</p>, <p>At this time following morphological data is used and provided</p>, <ul><li>Perseus<ul><li>arabic: 97.249 forms</li><li>greek: 1.020.846 forms</li><li>latin: 710.620 forms</li></ul></li><li>Celex<ul><li>dutch: 381.275 forms and 124.136 lemmas</li><li>english: 160.595 forms and 52.447 lemmas</li><li>german: 365.530 forms and 51.728 lemmas</li></ul></li><li>Lexique<ul><li>french: 306.795 forms</li></ul></li></ul>)
   else if ($info = 'docInterfaceOperation')
--- a/software/eXist/webapp/mpdl/interface/lt/wordInfo.xql	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/interface/lt/wordInfo.xql	Tue Apr 19 16:51:59 2011 +0200
@@ -184,8 +184,10 @@
           then concat("http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:1999.04.0060:entry=", $l)
           else if ($lexName = "wikiwoordenboek")
           then concat("http://nl.wiktionary.org/wiki/", $l)
-          else if ($lexName = "linyutan")
+          else if ($lexName = "linyutan" and string-length($l) = 1)
           then concat("http://humanum.arts.cuhk.edu.hk/cgi-bin/agrep-lindict?query=", $lLink, "&amp;category=wholerecord")
+          else if ($lexName = "linyutan" and string-length($l) > 1)
+          then concat("http://humanum.arts.cuhk.edu.hk/cgi-bin/agrep-lindict?query=", $lLink)
           else if ($lexName = "ctp")
           then concat("http://ctext.org/dictionary.pl?if=en&amp;char=", $l)
           else if ($lexName = "chinese-wiktionary")
--- a/software/eXist/webapp/mpdl/interface/page-fragment.xql	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/interface/page-fragment.xql	Tue Apr 19 16:51:59 2011 +0200
@@ -21,6 +21,7 @@
 let $reqPN := number(request:get-parameter("pn", "-1"))
 let $reqPF := request:get-parameter("pf", "")
 let $reqSN := number(request:get-parameter("sn", "-1"))
+let $xPointer := request:get-parameter("xpointer", "")
 let $highlightQuery := request:get-parameter("highlightQuery", "")
 let $regCharNorm := request:get-parameter("characterNormalization", "")
 let $tmpCharNorm := string-join($regCharNorm, ',')
@@ -231,7 +232,7 @@
   else ()
 let $returnPageFragmentTmp := util:parse($retPageFragment)  (: returns a valid xml document for that string   :)  
 
-let $externalElementsTmpTmp := mpdltext:externalObject("read", "element", concat("<object uid='joe' documentId='", $mpdlDocUri, "' pageNumber='", $pn, "'></object>"))
+let $externalElementsTmpTmp := mpdltext:externalObject("read", "element", concat("<object uid=&quot;joe&quot; documentId=&quot;", $mpdlDocUri, "&quot; xpointer=&quot;", "#xpointer(id(", "'page", $pn, "'", "))&quot;></object>"))
 let $externalElementsTmp := 
   if(not($externalElementsTmpTmp = ""))
   then util:parse($externalElementsTmpTmp)
@@ -244,10 +245,11 @@
 let $returnPageFragmentWithExtObjects :=
   <result>
     <externalElements>{$externalElements}</externalElements>
+    <xpointer>{$xPointer}</xpointer>
     <fragment>{$returnPageFragmentTmp}</fragment>
   </result>
 let $returnPageFragment := 
-  if (contains($options, "withXmlNodeId") or $containsExternalElements)
+  if (contains($options, "withXmlNodeId") or $containsExternalElements or $xPointer != '')
   then mpdl-text:transform($returnPageFragmentWithExtObjects, concat($presentationPath, "/insertExternalElements.xsl"))
   else $returnPageFragmentTmp
 
@@ -377,7 +379,7 @@
       <performance>{$neededTime}</performance>
     </result>
   else if ($errorCode = 10)
-  then <error><number>{$errorCode}</number><description>Fulltext document: {$mpdlDocUri} is not available yet</description></error>
+  then <error><number>{$errorCode}</number><description>Can't find fulltext document: {$mpdlDocUri} </description></error>
   else if ($errorCode = 11)
   then <error><number>{$errorCode}</number><description>No result: Page {$pn} not found</description></error>
   else if ($errorCode = 12)
@@ -386,7 +388,7 @@
 
 let $declare := 
   if ($errorCode > 9 or $mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml")
-  then util:declare-option("exist:serialize", "method=xhtml media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8")
+  then util:declare-option("exist:serialize", "method=xhtml media-type=text/html omit-xml-declaration=no indent=no encoding=utf-8")
   else if ($mode = "pureXml")
   then util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8")
   else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8")
--- a/software/eXist/webapp/mpdl/page-query-result.xql	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/page-query-result.xql	Tue Apr 19 16:51:59 2011 +0200
@@ -21,6 +21,7 @@
 let $reqPN := number(request:get-parameter("pn", "-1"))
 let $reqPF := request:get-parameter("pf", "")
 let $reqSN := number(request:get-parameter("sn", "-1"))
+let $xPointer := request:get-parameter("xpointer", "")
 let $query := request:get-parameter("query", "")
 let $reqQueryResultPN := request:get-parameter("query-result-pn", "")
 let $queryResultPN := 
@@ -273,7 +274,7 @@
   else ()
 let $returnPageFragmentTmp := util:parse($retPageFragment)  (: returns a valid xml document for that string   :)  
 
-let $externalElementsTmpTmp := mpdltext:externalObject("read", "element", concat("<object uid='joe' documentId='", $mpdlDocUri, "' pageNumber='", $pn, "'></object>"))
+let $externalElementsTmpTmp := mpdltext:externalObject("read", "element", concat("<object uid=&quot;joe&quot; documentId=&quot;", $mpdlDocUri, "&quot; xpointer=&quot;", "#xpointer(id(", "'page", $pn, "'", "))&quot;></object>"))
 let $externalElementsTmp := 
   if(not($externalElementsTmpTmp = ""))
   then util:parse($externalElementsTmpTmp)
@@ -286,10 +287,11 @@
 let $returnPageFragmentWithExtObjects :=
   <result>
     <externalElements>{$externalElements}</externalElements>
+    <xpointer>{$xPointer}</xpointer>
     <fragment>{$returnPageFragmentTmp}</fragment>
   </result>
 let $returnPageFragment := 
-  if (contains($options, "withXmlNodeId") or $containsExternalElements)
+  if (contains($options, "withXmlNodeId") or $containsExternalElements or $xPointer != '')
   then mpdl-text:transform($returnPageFragmentWithExtObjects, concat($presentationPath, "/insertExternalElements.xsl"))
   else $returnPageFragmentTmp
 
@@ -399,7 +401,7 @@
       <performance>{$neededTime}</performance>
     </result>
   else if ($errorCode = 10)
-  then <error><number>{$errorCode}</number><description>Fulltext document: {$mpdlDocUri} is not available yet</description></error>
+  then <error><number>{$errorCode}</number><description>Can't find fulltext document: {$mpdlDocUri} </description></error>
   else if ($errorCode = 11)
   then <error><number>{$errorCode}</number><description>No result: Page {$pn} not found</description></error>
   else if ($errorCode = 12)
@@ -408,7 +410,7 @@
 
 let $declare := 
   if ($errorCode > 9 or $mode = "text" or $mode = "textPollux" or $mode = "gis" or $mode = "image" or $mode = "xml")
-  then util:declare-option("exist:serialize", "method=xhtml media-type=text/html omit-xml-declaration=no indent=yes encoding=utf-8")
+  then util:declare-option("exist:serialize", "method=xhtml media-type=text/html omit-xml-declaration=no indent=no encoding=utf-8")
   else if ($mode = "pureXml")
   then util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8")
   else util:declare-option("exist:serialize", "method=xml media-type=text/xml omit-xml-declaration=no indent=yes encoding=utf-8")
--- a/software/eXist/webapp/mpdl/presentation/functions-mpdl.xsl	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/presentation/functions-mpdl.xsl	Tue Apr 19 16:51:59 2011 +0200
@@ -70,14 +70,14 @@
       </xsl:otherwise>
     </xsl:choose>
   </xsl:variable>
-  <xsl:variable name="figureText" select="concat('[Figure: ', $figureNumber, ']')"/>
+  <xsl:variable name="figureText" select="concat('[Figure ', $figureNumber, ']')"/>
   <div class="{$class}" style="{$style}">
-    <xsl:if test="$figureCaption != ''"><xsl:sequence select="$figureCaption"/><br/></xsl:if>
     <xsl:sequence select="$figureContent"/>
     <br/>
     <xsl:value-of select="$figureText"/>
-    <xsl:if test="$figureDescription != ''"><xsl:value-of select="': '"/><xsl:sequence select="$figureDescription"/></xsl:if>
-    <xsl:if test="$figureVariables != ''"><xsl:value-of select="'(Variables: '"/><xsl:sequence select="$figureVariables"/><xsl:value-of select="')'"/></xsl:if>
+    <xsl:if test="$figureCaption != ''"><xsl:value-of select="': '"/><xsl:sequence select="$figureCaption"/><br/></xsl:if>
+    <xsl:if test="$figureDescription != ''"><xsl:sequence select="$figureDescription"/><br/></xsl:if>
+    <xsl:if test="$figureVariables != ''"><xsl:sequence select="$figureVariables"/></xsl:if>
   </div>
 </xsl:function>
 
@@ -89,7 +89,7 @@
     <img title="Handwritten: {$href} not scanned" alt="Handwritten: {$href} not scanned" src="images/camera.png" width="30" height="30" border="0"/>
     <br/>
     <xsl:value-of select="$handwrittenText"/>
-    <p/>
+    <br/>
   </div>
 </xsl:function>
 
--- a/software/eXist/webapp/mpdl/presentation/insertExternalElements.xsl	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/presentation/insertExternalElements.xsl	Tue Apr 19 16:51:59 2011 +0200
@@ -11,6 +11,58 @@
 <xsl:output name="myXml" indent="yes" omit-xml-declaration="yes"/>
 
 <xsl:variable name="externalElements" select="/result/externalElements"/>
+<xsl:variable name="xpointer" select="/result/xpointer"/>
+<xsl:variable name="xpointerPath">
+  <xsl:choose>
+    <xsl:when test="contains($xpointer, '/range(')">
+      <xsl:value-of select="substring-before($xpointer, '/range(')"/>
+    </xsl:when>
+    <xsl:when test="contains($xpointer, '/point(')">
+      <xsl:value-of select="substring-before($xpointer, '/point(')"/>
+    </xsl:when>
+    <xsl:otherwise><xsl:value-of select="$xpointer"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="xpointerRange">
+  <xsl:choose>
+    <xsl:when test="contains($xpointer, '/range(')">
+      <xsl:value-of select="substring-before(substring-after($xpointer, '/range('), ')')"/>
+    </xsl:when>
+    <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="xpointerPoint">
+  <xsl:choose>
+    <xsl:when test="contains($xpointer, '/point(')">
+      <xsl:value-of select="substring-before(substring-after($xpointer, '/point('), ')')"/>
+    </xsl:when>
+    <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="xpointerRangeFromTmp" select="substring-before($xpointerRange, ',')"/>
+<xsl:variable name="xpointerRangeFrom">
+  <xsl:choose>
+    <xsl:when test="$xpointerRangeFromTmp = ''">
+      <xsl:value-of select="xs:integer(0)"/>
+    </xsl:when>
+    <xsl:when test="contains($xpointerRangeFromTmp, '-')">
+      <xsl:value-of select="xs:integer(0)"/>
+    </xsl:when>
+    <xsl:otherwise><xsl:value-of select="xs:integer($xpointerRangeFromTmp)"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+<xsl:variable name="xpointerRangeToTmp" select="substring-after($xpointerRange, ',')"/>
+<xsl:variable name="xpointerRangeTo">
+  <xsl:choose>
+    <xsl:when test="$xpointerRangeToTmp = ''">
+      <xsl:value-of select="xs:integer(0)"/>
+    </xsl:when>
+    <xsl:when test="contains($xpointerRangeToTmp, '-')">
+      <xsl:value-of select="xs:integer(0)"/>
+    </xsl:when>
+    <xsl:otherwise><xsl:value-of select="xs:integer($xpointerRangeToTmp)"/></xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
 <xsl:variable name="fragment" select="/result/fragment"/>
 
 <xsl:template match="result">
@@ -19,8 +71,8 @@
 <xsl:template match="fragment">
   <xsl:apply-templates/>
 </xsl:template>
-<xsl:template match="externalElements">
-</xsl:template>
+<xsl:template match="externalElements"></xsl:template>
+<xsl:template match="xpointer"></xsl:template>
 
 <xsl:template match="attribute()|text()|comment()|processing-instruction()">
   <xsl:copy>
@@ -35,46 +87,47 @@
   <xsl:variable name="extElemIndex" select="index-of($extElemXmlNodeIds, $elemXmlNodeId)"/>
   <xsl:variable name="extElem" select="$externalElements/*[$extElemIndex]"/>
   <xsl:variable name="extElemContent" select="$extElem/content/*[1]"/>
-  <xsl:variable name="extElemContentSerialized" select="saxon:serialize($extElemContent, 'myXml')"/>
-  <xsl:variable name="before">
+  <xsl:variable name="extElemXPointer" select="$extElem/@xpointer"/>
+  <xsl:variable name="extElemXPointerPoint" select="substring-before(substring-after($extElemXPointer, '/point('), ')')"/>
+  <xsl:variable name="extElemXPointerPointInt">
     <xsl:choose>
-      <xsl:when test="empty($extElem/@before) or $extElem/@before = ''">
-        <xsl:value-of select="''"/>
+      <xsl:when test="$extElemXPointerPoint != '.0' and $extElemXPointerPoint != '.1' and $extElemXPointerPoint != ''">
+        <xsl:value-of select="xs:integer($extElemXPointerPoint)"/>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:value-of select="string($extElem/@before)"/>
+        <xsl:value-of select="xs:integer(-1)"/>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:variable>
-  <xsl:variable name="charPos">
+  <xsl:variable name="insertedXPointer">
     <xsl:choose>
-      <xsl:when test="empty($extElem/@charPos) or $extElem/@charPos = ''">
-        <xsl:value-of select="xs:integer(-1)"/>
+      <xsl:when test="$xpointerRange != ''">
+        <xsl:variable name="elemSerialized" select="saxon:serialize(., 'myXml')"/>
+        <xsl:variable name="tmp" select="mpdlxmlutil:insertAtCharPos(mpdlxmlutil:new(), $elemSerialized, string($xpointerRangeFrom), '&lt;seg rend=&quot;highlight&quot;&gt;')"/>
+        <xsl:variable name="tmp2" select="mpdlxmlutil:insertAtCharPos(mpdlxmlutil:new(), $tmp, string($xpointerRangeTo), '&lt;/seg&gt;')"/>
+        <xsl:sequence select="saxon:parse($tmp2)"/>
+      </xsl:when>
+      <xsl:when test="$xpointerPoint = '.0'">
+        <xsl:variable name="elemSerialized" select="saxon:serialize(., 'myXml')"/>
+        <xsl:variable name="tmp" select="'&lt;bla&gt;'"/><xsl:value-of select="'&lt;seg rend=&quot;highlightPoint&quot;/&gt;'"/><xsl:value-of select="$elemSerialized"/><xsl:value-of select="'&lt;/bla&gt;'"/>
+        <xsl:sequence select="saxon:parse($tmp)"/>
+      </xsl:when>
+      <xsl:when test="$xpointerPoint = '.1'">
+        <xsl:variable name="elemSerialized" select="saxon:serialize(., 'myXml')"/>
+        <xsl:variable name="tmp" select="'&lt;bla&gt;'"/><xsl:value-of select="$elemSerialized"/><xsl:value-of select="'&lt;seg rend=&quot;highlightPoint&quot;/&gt;'"/><xsl:value-of select="'&lt;/bla&gt;'"/>
+        <xsl:sequence select="saxon:parse($tmp)"/>
+      </xsl:when>
+      <xsl:when test="$xpointerPoint != ''">
+        <xsl:variable name="elemSerialized" select="saxon:serialize(., 'myXml')"/>
+        <xsl:variable name="tmp" select="mpdlxmlutil:insertAtCharPos(mpdlxmlutil:new(), $elemSerialized, string($xpointerPoint), '&lt;seg rend=&quot;highlightPoint&quot;/&gt;')"/>
+        <xsl:sequence select="saxon:parse($tmp)"/>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:sequence select="xs:integer($extElem/@charPos)"/>
+        <xsl:value-of select="''"/>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:variable>
-  <xsl:variable name="elemSerialized" select="saxon:serialize(., 'myXml')"/>
-  <xsl:variable name="insertedElemSerialized" select="mpdlxmlutil:insertAtCharPos(mpdlxmlutil:new(), $elemSerialized, string($charPos), $extElemContentSerialized)"/>
-  <xsl:variable name="insertedElemDeSerializedTmp" select="saxon:parse($insertedElemSerialized)"/>
-  <xsl:variable name="insertedElemDeSerialized">
-    <xsl:element name="{name()}">
-      <xsl:apply-templates select="attribute()"/>
-      <xsl:attribute name="xmlNodeId">
-        <xsl:value-of select="$elemXmlNodeId"/>
-      </xsl:attribute>
-      <xsl:sequence select="$insertedElemDeSerializedTmp/*[1]/node()"/>
-    </xsl:element>
-  </xsl:variable>
-  <xsl:if test="$charPos &lt; 0 and $before = 'true'">
-    <xsl:sequence select="$extElemContent"/>
-  </xsl:if>
-  <xsl:if test="$charPos &gt;= 0">
-    <xsl:sequence select="$insertedElemDeSerialized"/>
-  </xsl:if>
-  <xsl:if test="$charPos &lt; 0">
+  <xsl:variable name="thisElement">
     <xsl:copy>
       <xsl:apply-templates select="attribute()"/>
       <xsl:attribute name="xmlNodeId">
@@ -82,8 +135,43 @@
       </xsl:attribute>
       <xsl:apply-templates select="element()|text()|comment()|processing-instruction()"/>
     </xsl:copy>
+  </xsl:variable>
+  <xsl:if test="$extElemXPointerPoint = '.0'">
+    <xsl:sequence select="$extElemContent"/>
   </xsl:if>
-  <xsl:if test="$charPos &lt; 0 and $before = 'false'">
+  <xsl:if test="$extElemXPointerPointInt &gt;= 0">
+    <xsl:variable name="extElemContent" select="$extElem/content/*[1]"/>
+    <xsl:variable name="extElemContentSerialized" select="saxon:serialize($extElemContent, 'myXml')"/>
+    <xsl:variable name="elemSerialized" select="saxon:serialize(., 'myXml')"/>
+    <xsl:variable name="insertedElemSerialized" select="mpdlxmlutil:insertAtCharPos(mpdlxmlutil:new(), $elemSerialized, string($extElemXPointerPointInt), $extElemContentSerialized)"/>
+    <xsl:variable name="insertedElemDeSerializedTmp" select="saxon:parse($insertedElemSerialized)"/>
+    <xsl:variable name="insertedElemDeSerialized">
+      <xsl:element name="{name()}">
+        <xsl:apply-templates select="attribute()"/>
+        <xsl:attribute name="xmlNodeId">
+          <xsl:value-of select="$elemXmlNodeId"/>
+        </xsl:attribute>
+        <xsl:sequence select="$insertedElemDeSerializedTmp/*[1]/node()"/>
+      </xsl:element>
+    </xsl:variable>
+    <xsl:sequence select="$insertedElemDeSerialized"/>
+  </xsl:if>
+  <xsl:if test="$extElemXPointerPoint = '.0' or $extElemXPointerPoint = '.1' or $extElemXPointerPoint = ''">
+    <xsl:choose>
+      <xsl:when test="$xpointerPath = $elemXmlNodeId and ($xpointerRange != '' or $xpointerPoint != '')">
+        <xsl:sequence select="$insertedXPointer"/>
+      </xsl:when>
+      <xsl:when test="$xpointerPath = $elemXmlNodeId and ($xpointerRange = '' and $xpointerPoint = '')">
+        <seg rend="highlight">
+          <xsl:sequence select="$thisElement"/>
+        </seg>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:sequence select="$thisElement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:if>
+  <xsl:if test="$extElemXPointerPoint = '.1'">
     <xsl:sequence select="$extElemContent"/>
   </xsl:if>
 </xsl:template>
--- a/software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl	Tue Apr 19 16:51:59 2011 +0200
@@ -11,8 +11,8 @@
   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:m="http://www.w3.org/1998/Math/MathML" 
-  xmlns:svg="http://www.w3.org/2000/svg" 
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:xhtml="http://www.w3.org/1999/xhtml">
 
 <xsl:import href="/db/mpdl/presentation/functions-mpdl.xsl" />
@@ -224,6 +224,46 @@
 
 <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" select="count($notes/note[contains(@place, 'bottom')])"/>
@@ -248,7 +288,8 @@
               <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:value-of select="concat('[↑ note-', $pageNumber, '-', $label, ']')"/>
+                <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>
@@ -279,7 +320,8 @@
           <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:value-of select="concat('[↑ ', $label, ']')"/>
+            <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+            <xsl:value-of select="$label"/>
           </a>
           <xsl:value-of select="': '"/>
           <xsl:choose>
@@ -303,9 +345,17 @@
 
 <!-- TEI: segmentation   -->
 <xsl:template match="seg" mode="text">
-  <span class="seg">
-    <xsl:apply-templates mode="text"/>
-  </span>
+  <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   -->
@@ -330,8 +380,14 @@
     <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 class="@rend"><xsl:apply-templates mode="text"/></span>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
@@ -349,7 +405,10 @@
       <span class="organization" title="Organization"><xsl:apply-templates mode="text"/></span>
     </xsl:when>
     <xsl:otherwise>
-      <span class="@type"><xsl:apply-templates mode="text"/></span>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
@@ -435,8 +494,60 @@
   </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="m:*" mode="text">
+<xsl:template match="math:*" mode="text">
   <xsl:element name="{name()}" namespace="">
     <xsl:copy-of select="@*"/>
     <xsl:apply-templates mode="text"/>
@@ -492,12 +603,23 @@
 
 <xsl:template match="p" mode="text">
   <xsl:variable name="style" select="@style"/>
-  <p>
-    <xsl:if test="not(empty($style))">
-      <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
-    </xsl:if>
-    <xsl:apply-templates mode="text"/>
-  </p>
+  <xsl:choose>
+    <xsl:when test="not(empty($style))">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
+          <xsl:apply-templates mode="text"/>
+        </span>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </div>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="lb" mode="text">
@@ -529,8 +651,8 @@
       <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="'super'"/></xsl:attribute>
-        <xsl:value-of select="concat(' ↓ (', $href, ') ')"/>
+        <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)">
@@ -551,8 +673,8 @@
           <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="'super'"/></xsl:attribute>
-            <xsl:value-of select="concat(' ↓ (', $href, ') ')"/>
+            <xsl:attribute name="class"><xsl:value-of select="'noteRef super'"/></xsl:attribute>
+            <xsl:value-of select="$href"/>
           </a>
         </xsl:otherwise>
       </xsl:choose>
@@ -564,8 +686,8 @@
 </xsl:template>
 
 <xsl:template match="emph" mode="text">
-  <xsl:variable name="class" select="@class"/>
   <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)"/>
@@ -578,17 +700,34 @@
       <xsl:otherwise>
         <xsl:choose>
           <xsl:when test="not(empty(w))">
-            <a class="textPollux" href="lt/wordInfo.xql?language={w/@lang}&amp;word={w/@form}&amp;output=html"><xsl:value-of select="$restChars"/></a>
+            <a class="textPollux" href="http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql?language={w/@lang}&amp;word={w/@form}&amp;output=html"><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:if test="$collectionName = 'echo' and not(contains($class, 'sc'))"><span class="{$class} {$style}"><xsl:apply-templates mode="text"/></span></xsl:if>
-  <xsl:if test="$collectionName = 'echo' and contains($class, 'sc') and $first2CharsAreUppercase"><span class="dc {$style}"><xsl:value-of select="$firstChar"/></span><span class="{$class} {$style}"><xsl:sequence select="$rest"/></span></xsl:if>
-  <xsl:if test="$collectionName = 'echo' and contains($class, 'sc') and not($first2CharsAreUppercase)"><span class="{$class} {$style}"><xsl:apply-templates mode="text"/></span></xsl:if>
-  <xsl:if test="$collectionName = 'archimedes'"><xsl:apply-templates mode="text"/></xsl:if>
+  <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 $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)">
+      <xsl:apply-templates mode="text"/>
+    </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'">
+      <xsl:apply-templates mode="text"/>
+    </xsl:when>
+    <xsl:otherwise><xsl:apply-templates mode="text"/></xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="foreign" mode="text">
@@ -673,24 +812,13 @@
           <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::echo:figure[empty(@xlink:label)]) + count(./preceding::echo:anchor[@type = 'figure'])"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
-      <xsl:variable name="figureCaption">
-        <xsl:choose>
-          <xsl:when test="not(empty($figure/echo:caption))"><xsl:value-of select="string-join($figure/echo:caption/text(), ' ')"/></xsl:when>
-          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
+      <xsl:variable name="figureCaption"><xsl:apply-templates mode="text" select="$figure/echo:caption"/></xsl:variable>
       <xsl:variable name="figureDescription">
-        <xsl:choose>
-          <xsl:when test="not(empty($figure/echo:description))"><xsl:value-of select="string-join($figure/echo:description/text(), ' ')"/></xsl:when>
-          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
-        </xsl:choose>
+        <xsl:for-each select="$figure/echo:description">
+          <xsl:apply-templates mode="text" select="."/><br/>
+        </xsl:for-each>
       </xsl:variable>
-      <xsl:variable name="figureVariables">
-        <xsl:choose>
-          <xsl:when test="not(empty($figure/echo:variables))"><xsl:value-of select="string-join($figure/echo:variables/text(), ' ')"/></xsl:when>
-          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
+      <xsl:variable name="figureVariables"><xsl:apply-templates mode="text" select="$figure/echo:variables"/></xsl:variable>
       <xsl:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float right')"/>
     </xsl:when>
     <xsl:when test="$type = 'handwritten'">
@@ -707,8 +835,8 @@
       <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="'super'"/></xsl:attribute>
-        <xsl:value-of select="concat('↓ (', $href, ')')"/>
+        <xsl:attribute name="class"><xsl:value-of select="'noteRef super'"/></xsl:attribute>
+        <xsl:value-of select="$href"/>
       </a>
     </xsl:when>
     <xsl:otherwise><a><xsl:attribute name="href"><xsl:value-of select="@xlink:href"/></xsl:attribute><xsl:apply-templates mode="text"/></a></xsl:otherwise>
@@ -754,7 +882,7 @@
         </xsl:if>
       </xsl:variable>
       <span class="place">
-        <a class="textPollux"><xsl:attribute name="href"><xsl:value-of select="$lexHref"/></xsl:attribute><xsl:value-of select="$wordStr"/></a>
+        <a class="place"><xsl:attribute name="href"><xsl:value-of select="$lexHref"/></xsl:attribute><xsl:value-of select="$wordStr"/></a>
       </span>
     </xsl:when>
     <xsl:when test="$mode = 'gis'">
@@ -804,12 +932,11 @@
 <xsl:template match="figure" mode="text">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
   <xsl:choose>
-    <xsl:when test="not($hasLabel)">
+    <xsl:when test="not($hasLabel) and $collectionName != 'tei'">
       <xsl:variable name="figureFileName">
         <xsl:choose>
           <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="replace(./@xlink:href, '/', '.')"/></xsl:when>
           <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="./image/@file"/></xsl:when>
-          <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="@facs"/></xsl:when>
           <xsl:otherwise><xsl:value-of select="./image/@file"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
@@ -817,19 +944,48 @@
         <xsl:choose>
           <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when>
           <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:when>
-          <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when>
           <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
-      <xsl:variable name="figureCaption" select="./caption/text()"/>
-      <xsl:variable name="figureDescription" select="./description/text()"/>
-      <xsl:variable name="figureVariables" select="./variables/text()"/>
+      <xsl:variable name="figureCaption"><xsl:apply-templates mode="text" select="caption"/></xsl:variable>
+      <xsl:variable name="figureDescription">
+        <xsl:for-each select="description">
+          <xsl:apply-templates mode="text" select="."/><br/>
+        </xsl:for-each>
+      </xsl:variable>
+      <xsl:variable name="figureVariables"><xsl:apply-templates mode="text" select="variables"/></xsl:variable>
       <xsl:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float none')"/>
     </xsl:when>
+    <xsl:when test="not($hasLabel) and $collectionName = 'tei'">
+      <xsl:variable name="figureNumber" select="$firstFigurePosition + count(./preceding::figure)"/>
+      <xsl:choose>
+        <xsl:when test="@facs != ''">
+          <xsl:sequence select="mpdl:showFigure($digilibAvailable, @facs, $figureNumber, '', '', '', 'float none')"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:variable name="href" select="graphic/@url"/>
+          <xsl:variable name="head" select="head"/>
+          <xsl:variable name="figDesc" select="string(figDesc)"/>
+          <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="concat('[Figure ', $figureNumber, ']: ')"/><xsl:value-of select="$head"/>
+          </div>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
     <xsl:otherwise></xsl:otherwise>
   </xsl:choose>
 </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">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
   <xsl:choose>
@@ -848,13 +1004,33 @@
   <xsl:variable name="baseUrlLex" select="'http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/'"/>
   <xsl:variable name="wordLanguage" select="@lang"/>
   <xsl:variable name="form" select="@form"/>
-  <a class="textPollux">
-    <xsl:attribute name="href"><xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute>
-    <xsl:apply-templates mode="text"/>
-  </a>
+  <xsl:choose>
+    <xsl:when test="not(empty(anchor))">
+      <xsl:for-each select="node()">
+        <xsl:choose>
+          <xsl:when test=". instance of text()">
+            <a class="textPollux">
+              <xsl:attribute name="href"><xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute>
+              <xsl:apply-templates mode="text" select="."/>
+            </a>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates mode="text" select="."/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:for-each>
+    </xsl:when>
+    <xsl:otherwise>
+      <a class="textPollux">
+        <xsl:attribute name="href"><xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </a>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="s" mode="text">
+  <xsl:variable name="style" select="@style"/>
   <xsl:variable name="actualSN">
     <xsl:choose>
       <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when>
@@ -867,13 +1043,27 @@
     <xsl:when test="$sn >= 0 and $sn = $actualSN">
       <span class="s highlight">
         <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if>
-        <xsl:apply-templates mode="text"/>
+        <xsl:choose>
+          <xsl:when test="empty(@style)">
+            <xsl:apply-templates mode="text"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <span class="{$style}"><xsl:apply-templates mode="text"/></span>
+          </xsl:otherwise>
+        </xsl:choose>
       </span>
     </xsl:when>
     <xsl:otherwise>
       <span class="s">
         <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if>
-        <xsl:apply-templates mode="text"/>
+        <xsl:choose>
+          <xsl:when test="empty(@style)">
+            <xsl:apply-templates mode="text"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <span class="{$style}"><xsl:apply-templates mode="text"/></span>
+          </xsl:otherwise>
+        </xsl:choose>
       </span>
     </xsl:otherwise>
   </xsl:choose>
--- a/software/eXist/webapp/mpdl/presentation/pageHtml.css	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/presentation/pageHtml.css	Tue Apr 19 16:51:59 2011 +0200
@@ -1,6 +1,5 @@
 /* general */
 .it        { font-style:italic }                    /* DESpecs: _ _ and attribute "it" */
-.it span.it { font-style:normal }                   /* DESpecs: _ _ within a paragraph already in italics */
 .bf        { font-weight:bold }                     /* DESpecs: <bf> */
 .sc        { font-variant:small-caps }              /* DESpecs: <sc> */
 .sub       { vertical-align:sub; font-size:.8em }   /* DESpecs: <_>  */ /* line-height:1em; ? */
@@ -24,6 +23,11 @@
 ul.xml.element { margin-left:0px;padding-left:8px }
 ul.xml.element.highlight { background-color:#D3D3D3; }      /* LightGrey    */
 
+/* Paragraphs     */
+div.p { 
+  margin: 1.12em 0px;
+}
+
 /* drop cap (Initiale)     */
 span.dc {
    float: left;
@@ -60,6 +64,19 @@
 span.foreign.la span.foreign.latin { color:green; } 
 /*  .....    */
 
+/* XPointer highligting    */
+span.seg.highlight { background-color:#D3D3D3; }  /* LightGrey    */
+span.seg.highlight:before {
+  content: url('../images/linkto.png');
+  margin-left: 0.1em;
+  margin-right: 0.1em;
+}
+span.seg.highlightPoint {
+  background: url('../images/linkto.png') no-repeat center center;
+  padding: 0.1em 0.5em 0.1em 0.1em;
+  margin-left: 0.5em;
+  margin-right: 0.1em;
+}
 
 /* indentation at the beginning of a paragraph: <emph class="sc it"> */
 span.sc { font-weight:bold; }
@@ -74,8 +91,12 @@
 div.blockquote { margin-left:10px; font-style:normal; }
 div.set-off { margin-left:10px; font-style:italic; }
 
-/* terminology     */
+/* dictionary / terminology     */
 span.term { color:purple; }  /* Blue   */
+span.entry { display:block; margin-bottom:20px;}
+span.entryDiv { margin-left:2em; display:block; margin-bottom:0.5em; margin-top:0.5em;}
+span.orth { font-weight:bold; }
+span.mentioned { font-style:italic; }
 
 /* notes     */
 span.note { font-style:italic; }
@@ -98,11 +119,41 @@
 /* sentence    */
 span.s.highlight { background-color:#D3D3D3; }  /* LightGrey    */
 span.s:hover { background-color:#D3D3D3; }      /* LightGrey    */
+span.s.it { font-style:italic; }
 
 /* highlighting    */
 span.hit.highlight { background-color:#77DD77; }  /* pastell green  */
 
-/* Links 
+/* Links   */
+a.textPollux:link {text-decoration: none; color: #892B06;}
+a.textPollux:visited {text-decoration: none; color: #892B06;}
+a.textPollux:hover {text-decoration: underline; color: #892B06;}
+/* Note Links   */
+a.note {
+  color: blue;
+  margin-right: 0.2em;
+}
+a.note:before {
+  content: url('../images/linkback.png');
+  margin-left: 0.1em;
+  margin-right: 0.2em;
+}
+a.note:link { text-decoration: none; }
+a.note:visited { text-decoration: none; }
+a.note:hover { text-decoration: underline; }
+a.noteRef {
+  color: blue;
+  margin-right: 0.2em;
+}
+a.noteRef:before {
+  content: url('../images/linkto.png');
+  margin-left: 0.1em;
+  margin-right: 0.2em;
+}
+a.noteRef:link { text-decoration: none; }
+a.noteRef:visited { text-decoration: none; }
+a.noteRef:hover { text-decoration: underline; }
+/*
 a:link {text-decoration: none;}
 a:visited {text-decoration: none}
 a:active {text-decoration: none}
--- a/software/eXist/webapp/mpdl/presentation/pageHtml.xsl	Tue Apr 19 16:51:26 2011 +0200
+++ b/software/eXist/webapp/mpdl/presentation/pageHtml.xsl	Tue Apr 19 16:51:59 2011 +0200
@@ -11,8 +11,8 @@
   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:m="http://www.w3.org/1998/Math/MathML" 
-  xmlns:svg="http://www.w3.org/2000/svg" 
+  xmlns:math="http://www.w3.org/1998/Math/MathML"
+  xmlns:svg="http://www.w3.org/2000/svg"
   xmlns:xhtml="http://www.w3.org/1999/xhtml">
 
 <xsl:import href="/db/mpdl/presentation/functions-mpdl.xsl" />
@@ -750,6 +750,46 @@
 
 <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" select="count($notes/note[contains(@place, 'bottom')])"/>
@@ -774,7 +814,8 @@
               <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:value-of select="concat('[↑ note-', $pageNumber, '-', $label, ']')"/>
+                <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>
@@ -805,7 +846,8 @@
           <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:value-of select="concat('[↑ ', $label, ']')"/>
+            <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+            <xsl:value-of select="$label"/>
           </a>
           <xsl:value-of select="': '"/>
           <xsl:choose>
@@ -829,9 +871,17 @@
 
 <!-- TEI: segmentation   -->
 <xsl:template match="seg" mode="text">
-  <span class="seg">
-    <xsl:apply-templates mode="text"/>
-  </span>
+  <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   -->
@@ -856,8 +906,14 @@
     <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 class="@rend"><xsl:apply-templates mode="text"/></span>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
@@ -875,7 +931,10 @@
       <span class="organization" title="Organization"><xsl:apply-templates mode="text"/></span>
     </xsl:when>
     <xsl:otherwise>
-      <span class="@type"><xsl:apply-templates mode="text"/></span>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="@type"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </span>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
@@ -961,8 +1020,60 @@
   </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="m:*" mode="text">
+<xsl:template match="math:*" mode="text">
   <xsl:element name="{name()}" namespace="">
     <xsl:copy-of select="@*"/>
     <xsl:apply-templates mode="text"/>
@@ -1018,12 +1129,23 @@
 
 <xsl:template match="p" mode="text">
   <xsl:variable name="style" select="@style"/>
-  <p>
-    <xsl:if test="not(empty($style))">
-      <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
-    </xsl:if>
-    <xsl:apply-templates mode="text"/>
-  </p>
+  <xsl:choose>
+    <xsl:when test="not(empty($style))">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
+          <xsl:apply-templates mode="text"/>
+        </span>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </div>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="lb" mode="text">
@@ -1055,8 +1177,8 @@
       <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="'super'"/></xsl:attribute>
-        <xsl:value-of select="concat(' ↓ (', $href, ') ')"/>
+        <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)">
@@ -1077,8 +1199,8 @@
           <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="'super'"/></xsl:attribute>
-            <xsl:value-of select="concat(' ↓ (', $href, ') ')"/>
+            <xsl:attribute name="class"><xsl:value-of select="'noteRef super'"/></xsl:attribute>
+            <xsl:value-of select="$href"/>
           </a>
         </xsl:otherwise>
       </xsl:choose>
@@ -1090,8 +1212,8 @@
 </xsl:template>
 
 <xsl:template match="emph" mode="text">
-  <xsl:variable name="class" select="@class"/>
   <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)"/>
@@ -1111,10 +1233,27 @@
       </xsl:otherwise>
     </xsl:choose>
   </xsl:variable>
-  <xsl:if test="$collectionName = 'echo' and not(contains($class, 'sc'))"><span class="{$class} {$style}"><xsl:apply-templates mode="text"/></span></xsl:if>
-  <xsl:if test="$collectionName = 'echo' and contains($class, 'sc') and $first2CharsAreUppercase"><span class="dc {$style}"><xsl:value-of select="$firstChar"/></span><span class="{$class} {$style}"><xsl:sequence select="$rest"/></span></xsl:if>
-  <xsl:if test="$collectionName = 'echo' and contains($class, 'sc') and not($first2CharsAreUppercase)"><span class="{$class} {$style}"><xsl:apply-templates mode="text"/></span></xsl:if>
-  <xsl:if test="$collectionName = 'archimedes'"><xsl:apply-templates mode="text"/></xsl:if>
+  <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 $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)">
+      <xsl:apply-templates mode="text"/>
+    </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'">
+      <xsl:apply-templates mode="text"/>
+    </xsl:when>
+    <xsl:otherwise><xsl:apply-templates mode="text"/></xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="foreign" mode="text">
@@ -1199,24 +1338,13 @@
           <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::echo:figure[empty(@xlink:label)]) + count(./preceding::echo:anchor[@type = 'figure'])"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
-      <xsl:variable name="figureCaption">
-        <xsl:choose>
-          <xsl:when test="not(empty($figure/echo:caption))"><xsl:value-of select="string-join($figure/echo:caption/text(), ' ')"/></xsl:when>
-          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
+      <xsl:variable name="figureCaption"><xsl:apply-templates mode="text" select="$figure/echo:caption"/></xsl:variable>
       <xsl:variable name="figureDescription">
-        <xsl:choose>
-          <xsl:when test="not(empty($figure/echo:description))"><xsl:value-of select="string-join($figure/echo:description/text(), ' ')"/></xsl:when>
-          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
-        </xsl:choose>
+        <xsl:for-each select="$figure/echo:description">
+          <xsl:apply-templates mode="text" select="."/><br/>
+        </xsl:for-each>
       </xsl:variable>
-      <xsl:variable name="figureVariables">
-        <xsl:choose>
-          <xsl:when test="not(empty($figure/echo:variables))"><xsl:value-of select="string-join($figure/echo:variables/text(), ' ')"/></xsl:when>
-          <xsl:otherwise><xsl:value-of select="''"/></xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
+      <xsl:variable name="figureVariables"><xsl:apply-templates mode="text" select="$figure/echo:variables"/></xsl:variable>
       <xsl:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float right')"/>
     </xsl:when>
     <xsl:when test="$type = 'handwritten'">
@@ -1233,8 +1361,8 @@
       <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="'super'"/></xsl:attribute>
-        <xsl:value-of select="concat('↓ (', $href, ')')"/>
+        <xsl:attribute name="class"><xsl:value-of select="'noteRef super'"/></xsl:attribute>
+        <xsl:value-of select="$href"/>
       </a>
     </xsl:when>
     <xsl:otherwise><a><xsl:attribute name="href"><xsl:value-of select="$href"/></xsl:attribute><xsl:apply-templates mode="text"/></a></xsl:otherwise>
@@ -1279,7 +1407,7 @@
         </xsl:if>
       </xsl:variable>
       <span class="place">
-        <a class="textPollux"><xsl:attribute name="href"><xsl:value-of select="$lexHref"/></xsl:attribute><xsl:value-of select="$wordStr"/></a>
+        <a class="place"><xsl:attribute name="href"><xsl:value-of select="$lexHref"/></xsl:attribute><xsl:sequence select="$wordStr"/></a>
       </span>
     </xsl:when>
     <xsl:when test="$mode = 'gis'">
@@ -1329,12 +1457,11 @@
 <xsl:template match="figure" mode="text">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
   <xsl:choose>
-    <xsl:when test="not($hasLabel)">
+    <xsl:when test="not($hasLabel) and $collectionName != 'tei'">
       <xsl:variable name="figureFileName">
         <xsl:choose>
           <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="replace(./@xlink:href, '/', '.')"/></xsl:when>
           <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="./image/@file"/></xsl:when>
-          <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="@facs"/></xsl:when>
           <xsl:otherwise><xsl:value-of select="./image/@file"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
@@ -1342,19 +1469,48 @@
         <xsl:choose>
           <xsl:when test="$collectionName = 'archimedes'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when>
           <xsl:when test="$collectionName = 'echo'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:when>
-          <xsl:when test="$collectionName = 'tei'"><xsl:value-of select="$firstFigurePosition + count(./preceding::figure)"/></xsl:when>
           <xsl:otherwise><xsl:value-of select="$firstFigurePosition + count(./preceding::figure[empty(@xlink:label)]) + count(./preceding::anchor[@type = 'figure'])"/></xsl:otherwise>
         </xsl:choose>
       </xsl:variable>
-      <xsl:variable name="figureCaption" select="./caption/text()"/>
-      <xsl:variable name="figureDescription" select="./description/text()"/>
-      <xsl:variable name="figureVariables" select="./variables/text()"/>
+      <xsl:variable name="figureCaption"><xsl:apply-templates mode="text" select="caption"/></xsl:variable>
+      <xsl:variable name="figureDescription">
+        <xsl:for-each select="description">
+          <xsl:apply-templates mode="text" select="."/><br/>
+        </xsl:for-each>
+      </xsl:variable>
+      <xsl:variable name="figureVariables"><xsl:apply-templates mode="text" select="variables"/></xsl:variable>
       <xsl:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float none')"/>
     </xsl:when>
+    <xsl:when test="not($hasLabel) and $collectionName = 'tei'">
+      <xsl:variable name="figureNumber" select="$firstFigurePosition + count(./preceding::figure)"/>
+      <xsl:choose>
+        <xsl:when test="@facs != ''">
+          <xsl:sequence select="mpdl:showFigure($digilibAvailable, @facs, $figureNumber, '', '', '', 'float none')"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:variable name="href" select="graphic/@url"/>
+          <xsl:variable name="head" select="head"/>
+          <xsl:variable name="figDesc" select="string(figDesc)"/>
+          <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="concat('[Figure ', $figureNumber, ']: ')"/><xsl:value-of select="$head"/>
+          </div>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
     <xsl:otherwise></xsl:otherwise>
   </xsl:choose>
 </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">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
   <xsl:choose>
@@ -1372,13 +1528,33 @@
 <xsl:template match="w" mode="text">
   <xsl:variable name="wordLanguage" select="@lang"/>
   <xsl:variable name="form" select="@form"/>
-  <a class="textPollux">
-    <xsl:attribute name="href"><xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute>
-    <xsl:apply-templates mode="text"/>
-  </a>
+  <xsl:choose>
+    <xsl:when test="not(empty(anchor))">
+      <xsl:for-each select="node()">
+        <xsl:choose>
+          <xsl:when test=". instance of text()">
+            <a class="textPollux">
+              <xsl:attribute name="href"><xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute>
+              <xsl:apply-templates mode="text" select="."/>
+            </a>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates mode="text" select="."/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:for-each>
+    </xsl:when>
+    <xsl:otherwise>
+      <a class="textPollux">
+        <xsl:attribute name="href"><xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute>
+        <xsl:apply-templates mode="text"/>
+      </a>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="s" mode="text">
+  <xsl:variable name="style" select="@style"/>
   <xsl:variable name="actualSN">
     <xsl:choose>
       <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when>
@@ -1391,13 +1567,27 @@
     <xsl:when test="$sn >= 0 and $sn = $actualSN">
       <span class="s highlight">
         <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if>
-        <xsl:apply-templates mode="text"/>
+        <xsl:choose>
+          <xsl:when test="empty(@style)">
+            <xsl:apply-templates mode="text"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <span class="{$style}"><xsl:apply-templates mode="text"/></span>
+          </xsl:otherwise>
+        </xsl:choose>
       </span>
     </xsl:when>
     <xsl:otherwise>
       <span class="s">
         <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if>
-        <xsl:apply-templates mode="text"/>
+        <xsl:choose>
+          <xsl:when test="empty(@style)">
+            <xsl:apply-templates mode="text"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <span class="{$style}"><xsl:apply-templates mode="text"/></span>
+          </xsl:otherwise>
+        </xsl:choose>
       </span>
     </xsl:otherwise>
   </xsl:choose>