diff software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl @ 13:469d927b9ca7

diverse Fehlerbehebungen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 19 Apr 2011 16:51:59 +0200
parents d6f528ad5d96
children e99964f390e4
line wrap: on
line diff
--- 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>