diff software/mpdl-services/mpiwg-mpdl-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/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-cms/src/de/mpg/mpiwg/berlin/mpdl/cms/transform/pageEcho.xsl	Tue Nov 27 12:35:19 2012 +0100
@@ -0,0 +1,536 @@
+<?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:de="http://www.mpiwg-berlin.mpg.de/ns/de/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 de math mml svg xhtml"
+  >
+
+<xsl:output method="xhtml" encoding="utf-8"/>
+
+<xsl:param name="echoFiguresDir"></xsl:param>
+<xsl:param name="echoPageImgDir"></xsl:param>
+
+<xsl:variable name="dictionaryServiceName" select="'http://mpdl-service.mpiwg-berlin.mpg.de/mpiwg-mpdl-lt-web/lt/GetDictionaryEntries'"/>
+
+<xsl:template match="*:echo">
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'echo'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:text">
+  <xsl:variable name="contentStr" select="normalize-space(string(.))"/>
+  <xsl:variable name="figures" select=".//*:figure|.//*:handwritten"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'text'"/></xsl:attribute>
+    <xsl:apply-templates/>
+    <xsl:if test="$contentStr = '' and empty($figures)">  <!-- test if div only contains empty nodes but no figures -->
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="'emptyPage'"/></xsl:attribute>
+        <xsl:value-of select="'[Empty page]'"/>
+      </div>
+    </xsl:if>
+  </div>
+  <!--   Notes                      -->
+  <xsl:variable name="bottomNotes" select="//*:note[contains(@position, 'foot') or empty(string(@position))]"/>
+  <xsl:variable name="countBottomNotes" select="count($bottomNotes)"/>
+  <xsl:if test="$countBottomNotes > 0">
+    <span class="notes">
+      <xsl:for-each select="$bottomNotes">
+        <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+        <span>
+          <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+          <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+          <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+          <span>
+            <xsl:attribute name="class"><xsl:value-of select="'noteBody foot'"/></xsl:attribute>
+            <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+            <xsl:apply-templates/>
+          </span>
+        </span>
+      </xsl:for-each>
+    </span>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:head">
+  <xsl:variable name="style" select="@style"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'head bf'"/></xsl:attribute>
+    <xsl:choose>
+      <xsl:when test="not(empty($style))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:figure">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="empty(@position)"><xsl:value-of select="name()"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat(name(), ' ', string(@position))"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="image" select="*:image"/>
+  <xsl:variable name="caption" select="*:caption"/>
+  <xsl:variable name="description" select="*:description"/>
+  <xsl:variable name="variables" select="*:variables"/>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:if test="not(empty($image))">
+      <xsl:variable name="file" select="$image/@file"/>
+      <xsl:variable name="pn" select="$image/@pn"/>
+      <xsl:variable name="wx" select="$image/@wx"/>
+      <xsl:variable name="wy" select="$image/@wy"/>
+      <xsl:variable name="ww" select="$image/@ww"/>
+      <xsl:variable name="wh" select="$image/@wh"/>
+      <xsl:variable name="digilibServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/jquery/digilib.html'"/>
+      <xsl:variable name="scalerServiceName" select="'http://digilib.mpiwg-berlin.mpg.de/digitallibrary/servlet/Scaler'"/>
+      <xsl:variable name="fileName">
+        <xsl:choose>
+          <xsl:when test="empty($wx) and empty($file)"><xsl:value-of select="$echoFiguresDir"/></xsl:when>
+          <xsl:when test="empty($wx) and not(empty($file))"><xsl:value-of select="concat($echoFiguresDir, '/', $file)"/></xsl:when>
+          <xsl:when test="not(empty($wx)) and empty($file)"><xsl:value-of select="$echoPageImgDir"/></xsl:when>
+          <xsl:when test="not(empty($wx)) and not(empty($file))"><xsl:value-of select="concat($echoPageImgDir, '/', $file)"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="$echoFiguresDir"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="digilibUrl">
+        <xsl:choose>
+          <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn)"/></xsl:when>
+          <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh)"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName)"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="scalerUrl">
+        <xsl:choose>
+          <xsl:when test="empty($pn) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;dh=200')"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and empty($wx)"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;dh=200')"/></xsl:when>
+          <xsl:when test="empty($pn) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200')"/></xsl:when>
+          <xsl:when test="not(empty($pn)) and not(empty($wx))"><xsl:value-of select="concat($scalerServiceName, '?fn=', $fileName, '&amp;pn=', $pn, '&amp;wx=', $wx, '&amp;wy=', $wy, '&amp;ww=', $ww, '&amp;wh=', $wh, '&amp;dh=200')"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="concat($digilibServiceName, '?fn=', $fileName, '&amp;dh=200')"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <a href="{$digilibUrl}">
+        <img>
+          <xsl:attribute name="src"><xsl:value-of select="$scalerUrl"/></xsl:attribute>
+        </img>
+      </a>
+    </xsl:if>
+    <xsl:if test="not(empty(@number))">
+      <xsl:variable name="type"><xsl:value-of select="'Figure'"/></xsl:variable>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'figureNumber'"/></xsl:attribute>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNum'"/></xsl:attribute>
+          <xsl:value-of select="string(@number)"/>
+        </span>
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'figureNumText'"/></xsl:attribute>
+          <xsl:value-of select="concat('[', $type, ' ', string(@number), ']')"/>
+        </span>
+      </span>
+    </xsl:if>
+    <xsl:if test="not(empty($caption))">
+      <xsl:for-each select="$caption">
+        <span class="caption"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(empty($description))">
+      <xsl:for-each select="$description">
+        <span class="description"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:if test="not(empty($variables))">
+      <xsl:for-each select="$variables">
+        <span class="variables"><xsl:apply-templates/></span>
+      </xsl:for-each>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<!-- MathML    -->
+<xsl:template match="math:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="mml:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<!-- XHTML: remove the xhtml namespace   -->
+<xsl:template match="xhtml:*">
+  <xsl:variable name="hasLabel" select="not(empty(@xhtml:label))"/>
+  <xsl:variable name="isTable" select="local-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/>
+      </xsl:element>
+    </xsl:when>
+    <xsl:otherwise></xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- SVG    -->
+<xsl:template match="svg:*">
+  <xsl:element name="{name()}" namespace="">
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:place|*:person">
+  <xsl:element name="span">
+    <xsl:attribute name="class"><xsl:value-of select="name()"/></xsl:attribute>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="*:div">
+  <xsl:if test="node() or normalize-space()">  <!-- test: contains nodes or is not empty -->
+    <div>
+      <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+      <xsl:attribute name="class"><xsl:value-of select="'div'"/></xsl:attribute>
+      <xsl:apply-templates/>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*:p">
+  <xsl:variable name="style" select="@style"/>
+  <xsl:variable name="class" select="'p'"/>
+  <div>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:choose>
+      <xsl:when test="not(empty($style))">
+        <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/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </div>
+</xsl:template>
+
+<xsl:template match="*:pb">
+  <xsl:variable name="number">
+    <xsl:choose>
+      <xsl:when test="not(empty(@n))"><xsl:value-of select="@n"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="count(./preceding::*:pb) + 1"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="file">
+    <xsl:choose>
+      <xsl:when test="not(empty(@file))"><xsl:value-of select="@file"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="$number"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'pb'"/></xsl:attribute>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'src'"/></xsl:attribute>
+      <xsl:attribute name="title"><xsl:value-of select="concat('pageimg/', string($file))"/></xsl:attribute>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'n'"/></xsl:attribute>
+        <xsl:value-of select="$number"/>
+      </span>
+      <xsl:if test="not(empty(@o))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'o'"/></xsl:attribute>
+          <xsl:value-of select="@o"/>
+        </span>
+      </xsl:if>
+      <xsl:if test="not(empty(@rhead))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="'rhead'"/></xsl:attribute>
+          <xsl:value-of select="@rhead"/>
+        </span>
+      </xsl:if>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:lb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'lb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:cb">
+  <br>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'cb'"/></xsl:attribute>
+  </br>
+</xsl:template>
+
+<xsl:template match="*:expan">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'expan'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:note">
+  <xsl:variable name="place"><xsl:value-of select="string(@position)"/></xsl:variable>
+  <xsl:variable name="noteSign"><xsl:value-of select="count(./preceding::*:note) + 1"/></xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'note'"/></xsl:attribute>
+    <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+    <xsl:if test="$place != '' and $place != 'foot'">
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('noteBody ', $place)"/></xsl:attribute>
+        <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:if>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:handwritten">
+  <xsl:variable name="noteSign"><xsl:value-of select="string(@number)"/></xsl:variable>
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'note handwritten'"/></xsl:attribute>
+    <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+    <span>
+      <xsl:attribute name="class"><xsl:value-of select="'noteBody'"/></xsl:attribute>
+      <span class="noteSign"><xsl:value-of select="$noteSign"/></span>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="'noteNumText'"/></xsl:attribute>
+        <xsl:value-of select="concat('[Handwritten note ', string(@number), ']')"/>
+      </span>
+    </span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:emph">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'emph'"/></xsl:attribute>
+    <xsl:choose>
+      <xsl:when test="not(empty(@style))">
+        <span>
+          <xsl:attribute name="class"><xsl:value-of select="string(@style)"/></xsl:attribute>
+          <xsl:apply-templates/>
+        </span>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:foreign">
+  <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>  
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="$language = ''"><xsl:value-of select="'foreign'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat('foreign ', $language)"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:q">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'q'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:quote">
+  <span class="quote">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:blockquote">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'blockquote'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:set-off">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'set-off'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:reg">
+  <span class="reg">
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'reg'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:var">
+  <xsl:variable name="class">
+    <xsl:choose>
+      <xsl:when test="empty(@type)"><xsl:value-of select="'var'"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="concat('var ', string(@type))"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>  
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:num">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:gap">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'gap'"/></xsl:attribute>
+    <xsl:if test="not(empty(@extent))"><span class="extent"><xsl:value-of select="string(@extent)"/></span></xsl:if>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:s">
+  <span>
+    <xsl:if test="not(empty(@xml:id))"><xsl:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute></xsl:if>
+    <xsl:attribute name="class"><xsl:value-of select="'s'"/></xsl:attribute>
+    <xsl:apply-templates/>
+  </span>
+</xsl:template>
+
+<!-- words  -->
+<xsl:template match="*:w">
+  <xsl:variable name="wordLanguage" select="@lang"/>
+  <xsl:variable name="form" select="encode-for-uri(string(@form))"/>
+  <xsl:variable name="dictionary" select="string(@dictionary)"/>
+  <xsl:variable name="displayWordOrig">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:orig))"><xsl:apply-templates select="*:orig/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordReg">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:reg))"><xsl:apply-templates select="*:reg/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordNorm">
+    <xsl:choose>
+      <xsl:when test="not(empty(*:norm))"><xsl:apply-templates select="*:norm/node()"/></xsl:when>
+      <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWordOrig)"/>
+  <xsl:variable name="dictionaryPart">
+    <xsl:choose>
+      <xsl:when test="$dictionary = 'true'">
+        <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>
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </a>
+      </xsl:when>
+      <xsl:otherwise>
+        <span class="dictionary">
+          <span class="orig"><xsl:sequence select="$displayWordOrig"/></span>
+          <span class="reg"><xsl:sequence select="$displayWordReg"/></span>
+          <span class="norm"><xsl:sequence select="$displayWordNorm"/></span>
+        </span>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <span class="w">
+    <xsl:sequence select="$dictionaryPart"/>
+    <span class="nodictionary orig"><xsl:sequence select="$displayWordOrig"/></span>
+    <span class="nodictionary reg"><xsl:sequence select="$displayWordReg"/></span>
+    <span class="nodictionary norm"><xsl:sequence select="$displayWordNorm"/></span>
+  </span>
+</xsl:template>
+
+<xsl:template match="*:hi">
+  <xsl:choose>
+    <xsl:when test="@type = 'elem'">
+      <div>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </div>
+    </xsl:when>
+    <xsl:otherwise>
+      <span>
+        <xsl:attribute name="class"><xsl:value-of select="concat('highlight ', @type)"/></xsl:attribute>
+        <xsl:apply-templates/>
+      </span>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>