comparison software/eXist/webapp/mpdl/presentation/pageFragmentHtml.xsl @ 15:e99964f390e4

diverse Fehlerbehebungen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Mon, 29 Aug 2011 17:40:19 +0200
parents 469d927b9ca7
children 7e883ce72fec
comparison
equal deleted inserted replaced
14:5df60f24e997 15:e99964f390e4
17 17
18 <xsl:import href="/db/mpdl/presentation/functions-mpdl.xsl" /> 18 <xsl:import href="/db/mpdl/presentation/functions-mpdl.xsl" />
19 <xsl:import href="/db/mpdl/presentation/functions-text.xsl" /> 19 <xsl:import href="/db/mpdl/presentation/functions-text.xsl" />
20 <xsl:import href="/db/mpdl/presentation/functions-util.xsl" /> 20 <xsl:import href="/db/mpdl/presentation/functions-util.xsl" />
21 21
22 <xsl:strip-space elements="*"/>
23
22 <xsl:output method="xhtml" encoding="utf-8"/> 24 <xsl:output method="xhtml" encoding="utf-8"/>
23 25
24 <xsl:variable name="mode" select="/result/page/mode"/> 26 <xsl:variable name="mode" select="/result/page/mode"/>
25 <xsl:variable name="language" select="/result/document-description/language"/> 27 <xsl:variable name="language" select="/result/document-description/language"/>
26 <xsl:variable name="sn" select="number(/result/page/sentence-number)"/> 28 <xsl:variable name="sn" select="number(/result/page/sentence-number)"/>
29 <xsl:variable name="highlightElement" select="/result/page/highlightElement"/>
30 <xsl:variable name="highlightElementPos" select="number(/result/page/highlightElementPos)"/>
27 <xsl:variable name="digilibAvailable" select="/result/page/digilib-available"/> 31 <xsl:variable name="digilibAvailable" select="/result/page/digilib-available"/>
28 <xsl:variable name="options" select="/result/page/options"/> 32 <xsl:variable name="options" select="/result/page/options"/>
29 <xsl:variable name="topPB" select="subsequence(//pb, 1, 1)"/> 33 <xsl:variable name="topPB" select="subsequence(//pb, 1, 1)"/>
30 <xsl:variable name="firstSentence" select="subsequence(//s, 1, 1)"/> 34 <xsl:variable name="firstSentence" select="subsequence(//s, 1, 1)"/>
31 <xsl:variable name="highlightQuery" select="string(/result/page/highlights/query)"/> 35 <xsl:variable name="highlightQuery" select="string(/result/page/highlights/query)"/>
131 </xsl:copy> 135 </xsl:copy>
132 </xsl:template> 136 </xsl:template>
133 137
134 <xsl:template match="element()|comment()|processing-instruction()" mode="xml"> 138 <xsl:template match="element()|comment()|processing-instruction()" mode="xml">
135 <xsl:variable name="elementName" select="name()"/> 139 <xsl:variable name="elementName" select="name()"/>
140 <xsl:variable name="countPrecedingElemsStr" select="concat('count(preceding::', $elementName, '[. >> $p1]) + 1')"/>
136 <xsl:variable name="elementPresentation"> 141 <xsl:variable name="elementPresentation">
137 <xsl:choose> 142 <xsl:choose>
138 <xsl:when test="element() = node() or text() != '' or self::comment() or self::processing-instruction()"> 143 <xsl:when test="element() = node() or text() != '' or self::comment() or self::processing-instruction()">
139 <xsl:value-of select="'&lt;'"/> 144 <xsl:value-of select="'&lt;'"/>
140 <span class="xml elementName"><xsl:value-of select="$elementName"/></span> 145 <span class="xml elementName"><xsl:value-of select="$elementName"/></span>
151 <xsl:apply-templates select="attribute()" mode="xml"/> 156 <xsl:apply-templates select="attribute()" mode="xml"/>
152 <xsl:value-of select="'/&gt;'"/> 157 <xsl:value-of select="'/&gt;'"/>
153 </xsl:otherwise> 158 </xsl:otherwise>
154 </xsl:choose> 159 </xsl:choose>
155 </xsl:variable> 160 </xsl:variable>
156 <xsl:variable name="actualSN"> 161 <xsl:variable name="currentHighlightElementPos">
157 <xsl:choose> 162 <xsl:choose>
158 <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when> 163 <xsl:when test="($highlightElement = 's' or $highlightElement = '') and . = $firstSentence and ($topPB >> .)">0</xsl:when>
159 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> 164 <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:value-of select="saxon:evaluate($countPrecedingElemsStr, $topPB)"/></xsl:when>
160 </xsl:choose> 165 <xsl:otherwise><xsl:value-of select="saxon:evaluate($countPrecedingElemsStr, $topPB)"/></xsl:otherwise>
161 </xsl:variable> 166 </xsl:choose>
162 <xsl:choose> 167 </xsl:variable>
163 <!-- Show the sentence in color light grey if it is given as sn --> 168 <xsl:variable name="class">
164 <xsl:when test="$elementName = 's' and $sn >= 0 and $sn = $actualSN"> 169 <xsl:choose>
165 <ul class="xml element highlight"> 170 <xsl:when test="($sn >= 0 and $sn = $currentHighlightElementPos) or ($elementName = $highlightElement and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos)"><xsl:value-of select="'xml element highlight'"/></xsl:when>
166 <a name="sn{$actualSN}"></a><xsl:sequence select="$elementPresentation"/> 171 <xsl:when test="$elementName = $highlightElement and $highlightElementPos >= 0 and $highlightElementPos != $currentHighlightElementPos"><xsl:value-of select="'xml element'"/></xsl:when>
167 </ul> 172 <xsl:otherwise><xsl:value-of select="'xml element'"/></xsl:otherwise>
168 </xsl:when> 173 </xsl:choose>
169 <xsl:when test="$elementName = 's' and $sn != $actualSN"> 174 </xsl:variable>
170 <ul class="xml element"> 175 <!-- Show the sentence in color light grey if it is given as highlightElementPos -->
171 <a name="sn{$actualSN}"></a><xsl:sequence select="$elementPresentation"/> 176 <ul class="{$class}" id="{$elementName}{$currentHighlightElementPos}">
172 </ul> 177 <xsl:sequence select="$elementPresentation"/>
173 </xsl:when> 178 </ul>
174 <xsl:otherwise>
175 <ul class="xml element">
176 <xsl:sequence select="$elementPresentation"/>
177 </ul>
178 </xsl:otherwise>
179 </xsl:choose>
180 </xsl:template> 179 </xsl:template>
181 180
182 <xsl:template match="attribute()" mode="xml"> 181 <xsl:template match="attribute()" mode="xml">
183 <xsl:variable name="attributeName" select="name()"/> 182 <xsl:variable name="attributeName" select="name()"/>
184 <span class="xml attributeName"> 183 <span class="xml attributeName">
189 <span class="xml attributeValue"><xsl:value-of select="."/></span><xsl:value-of select="'&quot;'"/> 188 <span class="xml attributeValue"><xsl:value-of select="."/></span><xsl:value-of select="'&quot;'"/>
190 <xsl:apply-templates select="attribute()" mode="xml"/> 189 <xsl:apply-templates select="attribute()" mode="xml"/>
191 </xsl:template> 190 </xsl:template>
192 191
193 <xsl:template match="text()" mode="xml"> 192 <xsl:template match="text()" mode="xml">
194 <xsl:variable name="parentS" select="./ancestor::s"/> 193 <xsl:variable name="highlightElementAncestor">
195 <xsl:variable name="actualSN"> 194 <xsl:choose>
196 <xsl:choose> 195 <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:sequence select="./ancestor::s"/></xsl:when>
197 <xsl:when test="$parentS = $firstSentence and ($topPB >> $parentS)">0</xsl:when> 196 <xsl:when test="$highlightElement = 'head'"><xsl:sequence select="./ancestor::head"/></xsl:when>
197 <xsl:otherwise><xsl:sequence select="./ancestor::s"/></xsl:otherwise>
198 </xsl:choose>
199 </xsl:variable>
200 <xsl:variable name="highlightElementAncestorType" select="name($highlightElementAncestor/*[1])"/>
201 <xsl:variable name="currentHighlightElementPos">
202 <xsl:choose>
203 <xsl:when test="($highlightElement = 's' or $highlightElement = '') and $highlightElementAncestor = $firstSentence and ($topPB >> $highlightElementAncestor)">0</xsl:when>
204 <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:when>
205 <xsl:when test="$highlightElement = 'head'"><xsl:value-of select="count(preceding::head[. >> $topPB]) + 1"/></xsl:when>
198 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> 206 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise>
199 </xsl:choose> 207 </xsl:choose>
200 </xsl:variable> 208 </xsl:variable>
201 <xsl:choose> 209 <xsl:choose>
202 <xsl:when test="$highlightQuery != '' and $sn >= 0 and $sn = $actualSN"> 210 <xsl:when test="$highlightQuery != '' and $highlightElementAncestorType = $highlightElement and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos">
203 <xsl:sequence select="text:highlight(string(.), $highlightQueryTerms, $highlightQueryWords, 'false')"/> 211 <xsl:sequence select="text:highlight(string(.), $highlightQueryTerms, $highlightQueryWords, 'false')"/>
204 </xsl:when> 212 </xsl:when>
205 <xsl:otherwise> 213 <xsl:otherwise>
206 <xsl:value-of select="."/> 214 <xsl:value-of select="."/>
207 </xsl:otherwise> 215 </xsl:otherwise>
338 </div> 346 </div>
339 </xsl:if> 347 </xsl:if>
340 </xsl:template> 348 </xsl:template>
341 349
342 <xsl:template match="head" mode="text"> 350 <xsl:template match="head" mode="text">
343 <p class="bf center"><xsl:apply-templates mode="text"/></p> 351 <xsl:variable name="currentHighlightElementPos">
352 <xsl:choose>
353 <xsl:when test="$highlightElement = 'head'"><xsl:value-of select="count(preceding::head[. >> $topPB]) + 1"/></xsl:when>
354 <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
355 </xsl:choose>
356 </xsl:variable>
357 <xsl:variable name="class">
358 <xsl:choose>
359 <xsl:when test="not(empty(@style)) and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"><xsl:value-of select="concat('head highlight bf ', @style)"/></xsl:when>
360 <xsl:when test="empty(@style) and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"><xsl:value-of select="'head highlight bf'"/></xsl:when>
361 <xsl:otherwise><xsl:value-of select="'head bf'"/></xsl:otherwise>
362 </xsl:choose>
363 </xsl:variable>
364 <p>
365 <span>
366 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
367 <xsl:attribute name="id"><xsl:value-of select="concat('head', $currentHighlightElementPos)"/></xsl:attribute>
368 <xsl:apply-templates mode="text"/>
369 </span>
370 </p>
344 </xsl:template> 371 </xsl:template>
345 372
346 <!-- TEI: segmentation --> 373 <!-- TEI: segmentation -->
347 <xsl:template match="seg" mode="text"> 374 <xsl:template match="seg" mode="text">
348 <xsl:choose> 375 <xsl:choose>
600 <xsl:apply-templates mode="text"/> 627 <xsl:apply-templates mode="text"/>
601 </div> 628 </div>
602 </xsl:template> 629 </xsl:template>
603 630
604 <xsl:template match="p" mode="text"> 631 <xsl:template match="p" mode="text">
632 <xsl:variable name="currentHighlightElementPos">
633 <xsl:choose>
634 <xsl:when test="$highlightElement = 'p'"><xsl:value-of select="count(preceding::p[. >> $topPB]) + 1"/></xsl:when>
635 <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise>
636 </xsl:choose>
637 </xsl:variable>
605 <xsl:variable name="style" select="@style"/> 638 <xsl:variable name="style" select="@style"/>
639 <xsl:variable name="class">
640 <xsl:choose>
641 <xsl:when test="not(empty(@style)) and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"><xsl:value-of select="concat('p highlight ', @style)"/></xsl:when>
642 <xsl:when test="empty(@style) and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"><xsl:value-of select="'p highlight'"/></xsl:when>
643 <xsl:otherwise><xsl:value-of select="'p'"/></xsl:otherwise>
644 </xsl:choose>
645 </xsl:variable>
606 <xsl:choose> 646 <xsl:choose>
607 <xsl:when test="not(empty($style))"> 647 <xsl:when test="not(empty($style))">
608 <div> 648 <div>
609 <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute> 649 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
610 <span> 650 <span>
611 <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute> 651 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
652 <xsl:attribute name="id"><xsl:value-of select="concat('p', $currentHighlightElementPos)"/></xsl:attribute>
612 <xsl:apply-templates mode="text"/> 653 <xsl:apply-templates mode="text"/>
613 </span> 654 </span>
614 </div> 655 </div>
615 </xsl:when> 656 </xsl:when>
616 <xsl:otherwise> 657 <xsl:otherwise>
617 <div> 658 <div>
618 <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute> 659 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
660 <xsl:attribute name="id"><xsl:value-of select="concat('p', $currentHighlightElementPos)"/></xsl:attribute>
619 <xsl:apply-templates mode="text"/> 661 <xsl:apply-templates mode="text"/>
620 </div> 662 </div>
621 </xsl:otherwise> 663 </xsl:otherwise>
622 </xsl:choose> 664 </xsl:choose>
623 </xsl:template> 665 </xsl:template>
636 <xsl:template match="cb" mode="text"> 678 <xsl:template match="cb" mode="text">
637 <br/><xsl:apply-templates mode="text"/> 679 <br/><xsl:apply-templates mode="text"/>
638 </xsl:template> 680 </xsl:template>
639 681
640 <xsl:template match="expan" mode="text"> 682 <xsl:template match="expan" mode="text">
641 <xsl:apply-templates mode="text"/> 683 <xsl:choose>
684 <xsl:when test="not(empty(@style))">
685 <span>
686 <xsl:attribute name="class"><xsl:value-of select="concat('expan ', @style)"/></xsl:attribute>
687 <xsl:apply-templates mode="text"/>
688 </span>
689 </xsl:when>
690 <xsl:otherwise>
691 <span class="expan"><xsl:apply-templates mode="text"/></span>
692 </xsl:otherwise>
693 </xsl:choose>
642 </xsl:template> 694 </xsl:template>
643 695
644 <xsl:template match="note" mode="text"> 696 <xsl:template match="note" mode="text">
645 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/> 697 <xsl:variable name="hasLabel" select="string(@xlink:label) != ''"/>
646 <xsl:variable name="place" select="@place"/> 698 <xsl:variable name="place" select="@place"/>
698 <xsl:choose> 750 <xsl:choose>
699 <xsl:when test="$length &lt; 2 or empty($length)"><xsl:value-of select="''"/></xsl:when> 751 <xsl:when test="$length &lt; 2 or empty($length)"><xsl:value-of select="''"/></xsl:when>
700 <xsl:otherwise> 752 <xsl:otherwise>
701 <xsl:choose> 753 <xsl:choose>
702 <xsl:when test="not(empty(w))"> 754 <xsl:when test="not(empty(w))">
703 <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> 755 <a class="textPollux" href="http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/lt/wordInfo.xql?language={w/@lang}&amp;display={$text}&amp;word={w/@form}&amp;output=html"><xsl:value-of select="$restChars"/></a>
704 </xsl:when> 756 </xsl:when>
705 <xsl:otherwise><xsl:value-of select="$restChars"/></xsl:otherwise> 757 <xsl:otherwise><xsl:value-of select="$restChars"/></xsl:otherwise>
706 </xsl:choose> 758 </xsl:choose>
707 </xsl:otherwise> 759 </xsl:otherwise>
708 </xsl:choose> 760 </xsl:choose>
709 </xsl:variable> 761 </xsl:variable>
710 <xsl:choose> 762 <xsl:choose>
711 <xsl:when test="$collectionName = 'echo' and not(contains($style, 'sc'))"> 763 <xsl:when test="$collectionName = 'echo' and not(contains($style, 'sc'))">
712 <span class="{$style}"><xsl:apply-templates mode="text"/></span> 764 <span class="{$style}"><xsl:apply-templates mode="text"/></span>
713 </xsl:when> 765 </xsl:when>
766 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and $length = 1">
767 <span class="sc"><xsl:value-of select="$firstChar"/></span>
768 </xsl:when>
714 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and $first2CharsAreUppercase"> 769 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and $first2CharsAreUppercase">
715 <span class="dc"><xsl:value-of select="$firstChar"/></span><span class="sc"><xsl:sequence select="$rest"/></span> 770 <span class="dc"><xsl:value-of select="$firstChar"/></span><span class="sc"><xsl:sequence select="$rest"/></span>
716 </xsl:when> 771 </xsl:when>
717 <xsl:when test="$collectionName = 'echo' and contains($style, 'sc') and $first2CharsAreUppercase"> 772 <xsl:when test="$collectionName = 'echo' and contains($style, 'sc') and $first2CharsAreUppercase">
718 <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> 773 <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>
719 </xsl:when> 774 </xsl:when>
720 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and not($first2CharsAreUppercase)"> 775 <xsl:when test="$collectionName = 'echo' and $style = 'sc' and not($first2CharsAreUppercase)">
721 <xsl:apply-templates mode="text"/> 776 <span class="sc"><xsl:apply-templates mode="text"/></span>
722 </xsl:when> 777 </xsl:when>
723 <xsl:when test="$collectionName = 'echo' and contains($style, 'sc') and not($first2CharsAreUppercase)"> 778 <xsl:when test="$collectionName = 'echo' and contains($style, 'sc') and not($first2CharsAreUppercase)">
724 <span class="sc"><span class="{$styleWithoutSC}"><xsl:apply-templates mode="text"/></span></span> 779 <span class="sc"><span class="{$styleWithoutSC}"><xsl:apply-templates mode="text"/></span></span>
725 </xsl:when> 780 </xsl:when>
726 <xsl:when test="$collectionName = 'archimedes'"> 781 <xsl:when test="$collectionName = 'archimedes'">
745 <xsl:apply-templates mode="text"/> 800 <xsl:apply-templates mode="text"/>
746 </span> 801 </span>
747 </xsl:template> 802 </xsl:template>
748 803
749 <xsl:template match="q" mode="text"> 804 <xsl:template match="q" mode="text">
750 <span class="q"><xsl:apply-templates mode="text"/></span> 805 <xsl:choose>
806 <xsl:when test="not(empty(@style))">
807 <span>
808 <xsl:attribute name="class"><xsl:value-of select="concat('q ', @style)"/></xsl:attribute>
809 <xsl:apply-templates mode="text"/>
810 </span>
811 </xsl:when>
812 <xsl:otherwise>
813 <span class="q"><xsl:apply-templates mode="text"/></span>
814 </xsl:otherwise>
815 </xsl:choose>
751 </xsl:template> 816 </xsl:template>
752 817
753 <xsl:template match="quote" mode="text"> 818 <xsl:template match="quote" mode="text">
754 <div class="quote"><xsl:apply-templates mode="text"/></div> 819 <xsl:choose>
820 <xsl:when test="not(empty(@style))">
821 <div>
822 <xsl:attribute name="class"><xsl:value-of select="concat('quote ', @style)"/></xsl:attribute>
823 <xsl:apply-templates mode="text"/>
824 </div>
825 </xsl:when>
826 <xsl:otherwise>
827 <div class="quote"><xsl:apply-templates mode="text"/></div>
828 </xsl:otherwise>
829 </xsl:choose>
755 </xsl:template> 830 </xsl:template>
756 831
757 <xsl:template match="blockquote" mode="text"> 832 <xsl:template match="blockquote" mode="text">
758 <div class="blockquote"><xsl:apply-templates mode="text"/></div> 833 <xsl:choose>
834 <xsl:when test="not(empty(@style))">
835 <div>
836 <xsl:attribute name="class"><xsl:value-of select="concat('blockquote ', @style)"/></xsl:attribute>
837 <xsl:apply-templates mode="text"/>
838 </div>
839 </xsl:when>
840 <xsl:otherwise>
841 <div class="blockquote"><xsl:apply-templates mode="text"/></div>
842 </xsl:otherwise>
843 </xsl:choose>
759 </xsl:template> 844 </xsl:template>
760 845
761 <xsl:template match="set-off" mode="text"> 846 <xsl:template match="set-off" mode="text">
762 <div class="set-off"><xsl:apply-templates mode="text"/></div> 847 <xsl:choose>
848 <xsl:when test="not(empty(@style))">
849 <div>
850 <xsl:attribute name="class"><xsl:value-of select="concat('set-off ', @style)"/></xsl:attribute>
851 <xsl:apply-templates mode="text"/>
852 </div>
853 </xsl:when>
854 <xsl:otherwise>
855 <div class="set-off"><xsl:apply-templates mode="text"/></div>
856 </xsl:otherwise>
857 </xsl:choose>
763 </xsl:template> 858 </xsl:template>
764 859
765 <xsl:template match="reg" mode="text"> 860 <xsl:template match="reg" mode="text">
766 <span class="reg"> 861 <xsl:choose>
767 <xsl:apply-templates mode="text"/> 862 <xsl:when test="not(empty(@style))">
768 </span> 863 <span>
864 <xsl:attribute name="class"><xsl:value-of select="concat('reg ', @style)"/></xsl:attribute>
865 <xsl:apply-templates mode="text"/>
866 </span>
867 </xsl:when>
868 <xsl:otherwise>
869 <span class="reg"><xsl:apply-templates mode="text"/></span>
870 </xsl:otherwise>
871 </xsl:choose>
769 </xsl:template> 872 </xsl:template>
770 873
771 <xsl:template match="var" mode="text"> 874 <xsl:template match="var" mode="text">
772 <xsl:variable name="type" select="@type"/> 875 <xsl:choose>
773 <span class="var"> 876 <xsl:when test="not(empty(@style))">
774 <xsl:attribute name="class"><xsl:value-of select="concat('var ', $type)"/></xsl:attribute> 877 <span>
775 <xsl:apply-templates mode="text"/> 878 <xsl:attribute name="class"><xsl:value-of select="concat('reg ', @type, ' ', @style)"/></xsl:attribute>
776 </span> 879 <xsl:apply-templates mode="text"/>
880 </span>
881 </xsl:when>
882 <xsl:otherwise>
883 <span class="var">
884 <xsl:attribute name="class"><xsl:value-of select="concat('var ', @type)"/></xsl:attribute>
885 <xsl:apply-templates mode="text"/>
886 </span>
887 </xsl:otherwise>
888 </xsl:choose>
777 </xsl:template> 889 </xsl:template>
778 890
779 <xsl:template match="num" mode="text"> 891 <xsl:template match="num" mode="text">
780 <span class="num"><xsl:apply-templates mode="text"/></span> 892 <xsl:choose>
893 <xsl:when test="not(empty(@style))">
894 <span>
895 <xsl:attribute name="class"><xsl:value-of select="'num'"/></xsl:attribute>
896 <span>
897 <xsl:attribute name="class"><xsl:value-of select="@style"/></xsl:attribute>
898 <xsl:apply-templates mode="text"/>
899 </span>
900 </span>
901 </xsl:when>
902 <xsl:otherwise>
903 <span class="num"><xsl:apply-templates mode="text"/></span>
904 </xsl:otherwise>
905 </xsl:choose>
781 </xsl:template> 906 </xsl:template>
782 907
783 <xsl:template match="gap" mode="text"> 908 <xsl:template match="gap" mode="text">
784 <xsl:variable name="extent" select="@extent"/> 909 <xsl:variable name="extent" select="@extent"/>
785 <xsl:variable name="count"> 910 <xsl:variable name="count">
1001 1126
1002 <!-- textPollux links --> 1127 <!-- textPollux links -->
1003 <xsl:template match="w" mode="text"> 1128 <xsl:template match="w" mode="text">
1004 <xsl:variable name="baseUrlLex" select="'http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/'"/> 1129 <xsl:variable name="baseUrlLex" select="'http://mpdl-proto.mpiwg-berlin.mpg.de/mpdl/interface/'"/>
1005 <xsl:variable name="wordLanguage" select="@lang"/> 1130 <xsl:variable name="wordLanguage" select="@lang"/>
1006 <xsl:variable name="form" select="@form"/> 1131 <xsl:variable name="form" select="encode-for-uri(@form)"/>
1132 <xsl:variable name="displayWord"><xsl:apply-templates mode="text"/></xsl:variable>
1133 <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWord)"/>
1007 <xsl:choose> 1134 <xsl:choose>
1008 <xsl:when test="not(empty(anchor))"> 1135 <xsl:when test="not(empty(anchor))">
1009 <xsl:for-each select="node()"> 1136 <xsl:for-each select="node()">
1137 <xsl:variable name="dispWord"><xsl:apply-templates mode="text" select="."/></xsl:variable>
1138 <xsl:variable name="dispWordUrlEncoded" select="encode-for-uri($dispWord)"/>
1010 <xsl:choose> 1139 <xsl:choose>
1011 <xsl:when test=". instance of text()"> 1140 <xsl:when test=". instance of text()">
1012 <a class="textPollux"> 1141 <a class="textPollux">
1013 <xsl:attribute name="href"><xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute> 1142 <xsl:attribute name="href"><xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&amp;display=', $dispWordUrlEncoded, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute>
1014 <xsl:apply-templates mode="text" select="."/> 1143 <xsl:sequence select="$dispWord"/>
1015 </a> 1144 </a>
1016 </xsl:when> 1145 </xsl:when>
1017 <xsl:otherwise> 1146 <xsl:otherwise>
1018 <xsl:apply-templates mode="text" select="."/> 1147 <xsl:sequence select="$dispWord"/>
1019 </xsl:otherwise> 1148 </xsl:otherwise>
1020 </xsl:choose> 1149 </xsl:choose>
1021 </xsl:for-each> 1150 </xsl:for-each>
1022 </xsl:when> 1151 </xsl:when>
1023 <xsl:otherwise> 1152 <xsl:otherwise>
1024 <a class="textPollux"> 1153 <a class="textPollux">
1025 <xsl:attribute name="href"><xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute> 1154 <xsl:attribute name="href"><xsl:value-of select="concat($baseUrlLex, 'lt/wordInfo.xql?language=', $wordLanguage, '&amp;display=', $displayWordUrlEncoded, '&amp;word=', $form, '&amp;output=html')"/></xsl:attribute>
1026 <xsl:apply-templates mode="text"/> 1155 <xsl:sequence select="$displayWord"/>
1027 </a> 1156 </a>
1028 </xsl:otherwise> 1157 </xsl:otherwise>
1029 </xsl:choose> 1158 </xsl:choose>
1030 </xsl:template> 1159 </xsl:template>
1031 1160
1032 <xsl:template match="s" mode="text"> 1161 <xsl:template match="s" mode="text">
1033 <xsl:variable name="style" select="@style"/> 1162 <xsl:variable name="style" select="@style"/>
1034 <xsl:variable name="actualSN"> 1163 <xsl:variable name="currentSN">
1035 <xsl:choose> 1164 <xsl:choose>
1036 <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when> 1165 <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when>
1037 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> 1166 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise>
1038 </xsl:choose> 1167 </xsl:choose>
1039 </xsl:variable> 1168 </xsl:variable>
1040 <a name="sn{$actualSN}"></a> 1169 <xsl:choose>
1041 <xsl:choose> 1170 <!-- Show the sentence in color light grey if it is given as sn or highlightElementPos -->
1042 <!-- Show the sentence in color light grey if it is given as sn --> 1171 <xsl:when test="($sn >= 0 and $sn = $currentSN) or ($highlightElement = 's' and $highlightElementPos >= 0 and $highlightElementPos = $currentSN)">
1043 <xsl:when test="$sn >= 0 and $sn = $actualSN"> 1172 <span class="s highlight" id="s{$currentSN}">
1044 <span class="s highlight">
1045 <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if> 1173 <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if>
1046 <xsl:choose> 1174 <xsl:choose>
1047 <xsl:when test="empty(@style)"> 1175 <xsl:when test="empty(@style)">
1048 <xsl:apply-templates mode="text"/> 1176 <xsl:apply-templates mode="text"/>
1049 </xsl:when> 1177 </xsl:when>
1052 </xsl:otherwise> 1180 </xsl:otherwise>
1053 </xsl:choose> 1181 </xsl:choose>
1054 </span> 1182 </span>
1055 </xsl:when> 1183 </xsl:when>
1056 <xsl:otherwise> 1184 <xsl:otherwise>
1057 <span class="s"> 1185 <span class="s" id="s{$currentSN}">
1058 <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if> 1186 <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if>
1059 <xsl:choose> 1187 <xsl:choose>
1060 <xsl:when test="empty(@style)"> 1188 <xsl:when test="empty(@style)">
1061 <xsl:apply-templates mode="text"/> 1189 <xsl:apply-templates mode="text"/>
1062 </xsl:when> 1190 </xsl:when>
1069 </xsl:choose> 1197 </xsl:choose>
1070 </xsl:template> 1198 </xsl:template>
1071 1199
1072 1200
1073 <xsl:template match="text()" mode="text"> 1201 <xsl:template match="text()" mode="text">
1074 <xsl:variable name="parentS" select="./ancestor::s"/> 1202 <xsl:variable name="highlightElementAncestor">
1075 <xsl:variable name="actualSN"> 1203 <xsl:choose>
1076 <xsl:choose> 1204 <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:sequence select="./ancestor::s"/></xsl:when>
1077 <xsl:when test="$parentS = $firstSentence and ($topPB >> $parentS)">0</xsl:when> 1205 <xsl:when test="$highlightElement = 'head'"><xsl:sequence select="./ancestor::head"/></xsl:when>
1206 <xsl:otherwise><xsl:sequence select="./ancestor::s"/></xsl:otherwise>
1207 </xsl:choose>
1208 </xsl:variable>
1209 <xsl:variable name="highlightElementAncestorType" select="name($highlightElementAncestor/*[1])"/>
1210 <xsl:variable name="currentHighlightElementPos">
1211 <xsl:choose>
1212 <xsl:when test="($highlightElement = 's' or $highlightElement = '') and $highlightElementAncestor = $firstSentence and ($topPB >> $highlightElementAncestor)">0</xsl:when>
1213 <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:when>
1214 <xsl:when test="$highlightElement = 'head'"><xsl:value-of select="count(preceding::head[. >> $topPB]) + 1"/></xsl:when>
1078 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> 1215 <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise>
1079 </xsl:choose> 1216 </xsl:choose>
1080 </xsl:variable> 1217 </xsl:variable>
1081 <xsl:choose> 1218 <xsl:choose>
1082 <xsl:when test="$highlightQuery != '' and $sn >= 0 and $sn = $actualSN"> 1219 <xsl:when test="$highlightQuery != '' and $highlightElementAncestorType = $highlightElement and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos">
1083 <xsl:sequence select="text:highlight(string(.), $highlightQueryTerms, $highlightQueryWords, 'false')"/> 1220 <xsl:sequence select="text:highlight(string(.), $highlightQueryTerms, $highlightQueryWords, 'false')"/>
1084 </xsl:when> 1221 </xsl:when>
1085 <xsl:otherwise> 1222 <xsl:otherwise>
1086 <xsl:value-of select="."/> 1223 <xsl:value-of select="."/>
1087 </xsl:otherwise> 1224 </xsl:otherwise>
1088 </xsl:choose> 1225 </xsl:choose>
1089 </xsl:template> 1226 </xsl:template>
1090 1227
1091 </xsl:stylesheet> 1228 </xsl:stylesheet>