diff software/eXist/webapp/mpdl/presentation/pageHtml.xsl @ 11:d6f528ad5d96

TEI Unterst?tzung, Fehlerbehebungen, externe Objekte
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Fri, 11 Mar 2011 13:34:02 +0100
parents 1ec29fdd0db8
children 469d927b9ca7
line wrap: on
line diff
--- a/software/eXist/webapp/mpdl/presentation/pageHtml.xsl	Fri Mar 11 13:33:26 2011 +0100
+++ b/software/eXist/webapp/mpdl/presentation/pageHtml.xsl	Fri Mar 11 13:34:02 2011 +0100
@@ -11,7 +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:mml="http://www.w3.org/1998/Math/MathML" 
+  xmlns:m="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,32 +751,45 @@
 <xsl:template match="text" mode="text">
   <xsl:apply-templates mode="text"/>
   <!--   Notes                      -->
-  <xsl:if test="$collectionName = 'archimedes' and count($notes/*) > 0">
+  <xsl:variable name="countEmptyPlaces" select="count($notes/note[empty(@place)])"/>
+  <xsl:variable name="countBottomPlaces" select="count($notes/note[contains(@place, 'bottom')])"/>
+  <xsl:if test="($collectionName = 'archimedes' or $collectionName = 'tei') and count($notes/*) > 0">
     <div>
-      <hr class="notesBottom"/>
+      <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(.)"/>
-        <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: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: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: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>
@@ -816,18 +830,153 @@
 <!-- TEI: segmentation   -->
 <xsl:template match="seg" mode="text">
   <span class="seg">
-    <xsl:if test="not(empty(@xlink:href))">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</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:otherwise>
+      <span class="@rend"><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 class="@type"><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="@xlink:href"/></xsl:attribute>
+        <xsl:attribute name="href"><xsl:value-of select="@target"/></xsl:attribute>
         <xsl:apply-templates mode="text"/>
       </a>
     </xsl:if>
-    <xsl:if test="empty(@xlink:href)">
+    <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: MathML    -->
+<xsl:template match="m:*" 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"/>
@@ -893,11 +1042,12 @@
 </xsl:template>
 
 <xsl:template match="expan" mode="text">
-  <xsl:apply-templates mode="text"/><xsl:text> </xsl:text>
+  <xsl:apply-templates mode="text"/>
 </xsl:template>
 
 <xsl:template match="note" mode="text">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
+  <xsl:variable name="place" select="@place"/>
   <xsl:variable name="notePos" select="count(preceding::note[. >> $topPB]) + 1"/>
   <xsl:variable name="href" select="concat('note-', $pageNumber, '-', $notePos)"/>
   <xsl:choose>
@@ -915,7 +1065,27 @@
         <span class="note"><xsl:apply-templates mode="text"/></span>
       </p>
     </xsl:when>
-    <xsl:otherwise></xsl:otherwise>
+    <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="'super'"/></xsl:attribute>
+            <xsl:value-of select="concat(' ↓ (', $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>
 
@@ -947,21 +1117,6 @@
   <xsl:if test="$collectionName = 'archimedes'"><xsl:apply-templates mode="text"/></xsl:if>
 </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>
-
 <xsl:template match="foreign" mode="text">
   <xsl:variable name="lang" select="@lang"/>
   <xsl:variable name="xmllang" select="@xml:lang"/>
@@ -979,7 +1134,7 @@
 </xsl:template>
 
 <xsl:template match="q" mode="text">
-  <div class="q"><xsl:apply-templates mode="text"/></div>
+  <span class="q"><xsl:apply-templates mode="text"/></span>
 </xsl:template>
 
 <xsl:template match="quote" mode="text">
@@ -1044,9 +1199,24 @@
           <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" select="string-join($figure/echo:caption/text(), ' ')"/>
-      <xsl:variable name="figureDescription" select="string-join($figure/echo:description/text(), ' ')"/>
-      <xsl:variable name="figureVariables" select="string-join($figure/echo:variables/text(), ' ')"/>
+      <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="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: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:sequence select="mpdl:showFigure($digilibAvailable, $figureFileName, $figureNumber, $figureCaption, $figureDescription, $figureVariables, 'float right')"/>
     </xsl:when>
     <xsl:when test="$type = 'handwritten'">
@@ -1092,13 +1262,20 @@
     <xsl:when test="$mode = 'textPollux'">
       <xsl:variable name="wordLanguage" select="string-join(w[1]/@lang, '')"/>
       <xsl:variable name="form" select="string-join(w/@form, '')"/>
-      <xsl:variable name="wordStr" select="string-join(w, '')"/>
+      <xsl:variable name="wordStr">
+        <xsl:if test="not(empty(w))">
+          <xsl:value-of select="string-join(w, '')"/>
+        </xsl:if>
+        <xsl:if test="empty(w)">
+          <xsl:value-of select="."/>
+        </xsl:if>
+      </xsl:variable>
       <xsl:variable name="lexHref">
         <xsl:if test="not(empty(w))">
           <xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
         </xsl:if>
         <xsl:if test="empty(w)">
-          <xsl:value-of select="concat('interface/lt/wordInfo.xql?type=place', '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
+          <xsl:value-of select="concat('interface/lt/wordInfo.xql?type=place', '&amp;language=', $language, '&amp;word=', $wordStr, '&amp;output=html', '&amp;placeHref=', encode-for-uri($href))"/>
         </xsl:if>
       </xsl:variable>
       <span class="place">
@@ -1134,11 +1311,6 @@
   </span>
 </xsl:template>
 
-<!-- MML   -->
-<xsl:template match="mml:*" mode="text">
-  <xsl:copy-of select="."/>
-</xsl:template>
-    
 <!-- XHTML: remove the xhtml namespace   -->
 <xsl:template match="xhtml:*" mode="text">
   <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
@@ -1162,6 +1334,7 @@
         <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>
@@ -1169,6 +1342,7 @@
         <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>
@@ -1194,7 +1368,6 @@
 </xsl:template>
 
 
-
 <!-- textPollux links                           -->
 <xsl:template match="w" mode="text">
   <xsl:variable name="wordLanguage" select="@lang"/>