diff software/mpdl-services/mpiwg-mpdl-xml/build/classes/de/mpg/mpiwg/berlin/mpdl/xml/transform/pageEcho.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/pageEcho.xsl	Tue Nov 27 12:35:19 2012 +0100
@@ -0,0 +1,485 @@
+<?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"
+  exclude-result-prefixes="xsl xlink xs functx saxon dc dcterms echo math mml svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="mode"></xsl:param>
+<xsl:param name="normalization"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:echo">
+  <span class="page">
+    <xsl:apply-templates mode="text"/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:anchor|*:figure|*:caption|*:description|*:handwritten|*:place|*:person" mode="text">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:text" mode="text">
+  <xsl:apply-templates mode="text"/>
+  <!--   Notes                      -->
+  <!--
+  <xsl:variable name="countEmptyPlaces" select="count($notes/note[empty(@place)])"/>
+  <xsl:variable name="countBottomPlaces">
+    <xsl:value-of select="count($notes/note[contains(@position, 'bottom') or empty(string(@position))])"/>
+  </xsl:variable>
+  <xsl:if test="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>
+
+<!-- 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>
+
+<!-- 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="*:pb" mode="text">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="text"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:lb" mode="text">
+  <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:value-of select="@position"/></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="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="not($hasLabel)">
+      <p>
+        <xsl:value-of select="'[Note]: '"/>
+        <span class="note"><xsl:apply-templates mode="text"/></span>
+      </p>
+    </xsl:when>
+    <xsl:when test="$hasLabel"></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="dictionary" href="{$dictionaryServiceName}?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="not(contains($style, 'sc'))">
+      <span class="{$style}"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="$style = 'sc' and $length = 1">
+      <span class="sc"><xsl:value-of select="$firstChar"/></span>
+    </xsl:when>
+    <xsl:when test="$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="$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="$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="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="$style = 'sc' and not($first2CharsAreUppercase)">
+      <span class="sc"><xsl:apply-templates mode="text"/></span>
+    </xsl:when>
+    <xsl:when test="contains($style, 'sc') and not($first2CharsAreUppercase)">
+      <span class="sc"><span class="{$styleWithoutSC}"><xsl:apply-templates mode="text"/></span></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>
+
+<!-- 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>
+
+
+<!-- words  -->
+<xsl:template match="*:w" mode="text">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="formNotUrlEncoded" select="string(@form)"/>
+  <xsl:variable name="formRegularized" select="string(@formRegularized)"/>
+  <xsl:variable name="formNormalized" select="string(@formNormalized)"/>
+  <xsl:variable name="lemmas" select="string(@lemmas)"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWord">
+    <xsl:choose>
+      <xsl:when test="$normalization = 'orig'"><xsl:apply-templates mode="text"/></xsl:when>
+      <xsl:when test="$normalization = 'reg' and $formRegularized = ''"><xsl:apply-templates mode="text"/></xsl:when>
+      <xsl:when test="$normalization = 'reg' and $formRegularized != ''"><xsl:sequence select="$formRegularized"/></xsl:when>
+      <xsl:when test="$normalization = 'norm'"><xsl:apply-templates mode="text"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates mode="text"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWord)"/>
+  <xsl:choose>
+    <xsl:when test="$dictionary = 'true' and $mode = 'tokenized'">
+      <a class="dictionary">
+        <xsl:attribute name="href"><xsl:value-of select="concat($dictionaryServiceName, '?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:when>
+    <xsl:otherwise><xsl:sequence select="$displayWord"/></xsl:otherwise>
+  </xsl:choose>
+</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>