Mercurial > hg > mpdl-group
diff software/eXist/webapp/mpdl/presentation/pageHtml.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 |
line wrap: on
line diff
--- a/software/eXist/webapp/mpdl/presentation/pageHtml.xsl Mon Aug 29 17:40:02 2011 +0200 +++ b/software/eXist/webapp/mpdl/presentation/pageHtml.xsl Mon Aug 29 17:40:19 2011 +0200 @@ -6,8 +6,8 @@ xmlns:functx="http://www.functx.com" xmlns:saxon="http://saxon.sf.net/" xmlns:mpdl="http://www.mpiwg-berlin.mpg.de/ns/mpdl" + xmlns:mpdl-util="http://www.mpiwg-berlin.mpg.de/ns/mpdl/util" xmlns:text="http://www.mpiwg-berlin.mpg.de/ns/mpdl/text" - xmlns:mpdl-util="http://www.mpiwg-berlin.mpg.de/ns/mpdl/util" 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/" @@ -19,6 +19,8 @@ <xsl:import href="/db/mpdl/presentation/functions-text.xsl" /> <xsl:import href="/db/mpdl/presentation/functions-util.xsl" /> +<xsl:strip-space elements="*"/> + <xsl:output method="xhtml" encoding="utf-8"/> <xsl:variable name="errorMessage" select="string(/result/query/result/error)"/> @@ -29,6 +31,8 @@ <xsl:variable name="queryResultPN" select="/result/query/result/pn"/> <xsl:variable name="language" select="/result/document-description/language"/> <xsl:variable name="sn" select="number(/result/page/sentence-number)"/> +<xsl:variable name="highlightElement" select="/result/page/highlightElement"/> +<xsl:variable name="highlightElementPos" select="number(/result/page/highlightElementPos)"/> <xsl:variable name="digilibAvailable" select="/result/page/digilib-available"/> <xsl:variable name="options" select="/result/page/options"/> <xsl:variable name="topPB" select="subsequence(//pb, 1, 1)"/> @@ -139,8 +143,11 @@ </xsl:choose> </td> <input type="hidden" name="pn" value="{$pageNumber}"/> - <xsl:if test="/result/page/sentence-number[node()]"> - <input type="hidden" name="sn" value="{$sn}"/> + <xsl:if test="/result/page/highlightElement[node()]"> + <input type="hidden" name="highlightElement" value="{$highlightElement}"/> + </xsl:if> + <xsl:if test="/result/page/highlightElementPos[node()]"> + <input type="hidden" name="highlightElementPos" value="{$highlightElementPos}"/> </xsl:if> <input type="hidden" name="query-type" value="{$queryType}"/> <xsl:if test="/result/query/result[node()]"> @@ -154,9 +161,6 @@ <input type="hidden" name="document" value="{$documentUri}"/> <input type="hidden" name="mode" value="{$mode}"/> <input type="hidden" name="pn" value="{$pageNumber}"/> - <xsl:if test="/result/page/sentence-number[node()]"> - <input type="hidden" name="sn" value="-1"/> - </xsl:if> <td><button id="bToc" name="query-type" value="toc" style="background: none; border: none;"><img src="images/toc.gif" width="24" height="24"/></button></td> <td><button id="bFulltext" name="query-type" value="fulltext" style="background: none; border: none;"><img src="images/search.gif" width="24" height="24"/></button></td> <td><button id="bFulltextMorph" name="query-type" value="fulltextMorph" style="background: none; border: none;"><img src="images/searchMorph.gif" width="24" height="24"/></button></td> @@ -428,7 +432,7 @@ <td> <xsl:variable name="resultSize" select="/result/query/result/size"/> <xsl:if test="$queryType = 'fulltext' or $queryType = 'fulltextMorph' or $queryType = 'fulltextMorphLemma'"> - <b><xsl:value-of select="$resultSize"/> sentence hits</b> + <b><xsl:value-of select="$resultSize"/> hits</b> </xsl:if> <xsl:if test="$queryType = 'ftIndex' or $queryType = 'ftIndexMorph'"> <b><xsl:value-of select="$resultSize"/> entries beginning with: "<xsl:value-of select="$query"/>"<br/></b> @@ -533,24 +537,29 @@ <xsl:variable name="term" select="term"/> <td><xsl:value-of select="$pos"/>.</td> <td align="left"> + <xsl:variable name="hitType" select="hitType"/> <xsl:variable name="hitPN" select="pn"/> - <xsl:variable name="hitPosOfS" select="pos-of-s"/> - <xsl:variable name="sSurroundsPB" select="s-surrounds-pb"/> + <xsl:variable name="hitString" select="hitString"/> + <xsl:variable name="hitPos" select="hitPos"/> + <xsl:variable name="hitSurroundsPB" select="hitSurroundsPB"/> <xsl:variable name="queryValue" select="concat('&', 'query=', $query)"/> <xsl:variable name="queryValueEscaped1" select="replace($queryValue, '\+', '%2B')"/> <xsl:variable name="queryValueEscaped2" select="replace($queryValueEscaped1, ' ', '+')"/> <xsl:choose> <!-- if a found sentence surrounds a page break then a special presentation of the hit is done --> - <xsl:when test="$sSurroundsPB = 'false'"> - <a href="?{$documentValue}&pn={$hitPN}&sn={$hitPosOfS}&{$modeValue}&query-type={$queryType}{$queryValueEscaped2}&query-result-pn={$queryResultPN}#sn{$hitPosOfS}">Page <xsl:value-of select="$hitPN"/>, Sentence <xsl:value-of select="$hitPosOfS"/></a> + <xsl:when test="$hitType = 's' and $hitSurroundsPB = 'false'"> + <a href="?{$documentValue}&pn={$hitPN}&{$modeValue}&query-type={$queryType}{$queryValueEscaped2}&query-result-pn={$queryResultPN}&highlightElement={$hitType}&highlightElementPos={$hitPos}#s{$hitPos}">Page <xsl:value-of select="$hitPN"/>, Sentence <xsl:value-of select="$hitPos"/></a> + </xsl:when> + <xsl:when test="$hitType = 'head'"> + <a href="?{$documentValue}&pn={$hitPN}&{$modeValue}&query-type={$queryType}{$queryValueEscaped2}&query-result-pn={$queryResultPN}&highlightElement={$hitType}&highlightElementPos={$hitPos}#head{$hitPos}">Page <xsl:value-of select="$hitPN"/>, Head <xsl:value-of select="$hitPos"/></a> </xsl:when> <xsl:otherwise> - <a href="?{$documentValue}&pn={$hitPN}&sn={$hitPosOfS}&{$modeValue}&query-type={$queryType}{$queryValueEscaped2}&query-result-pn={$queryResultPN}#sn{$hitPosOfS}">Page <xsl:value-of select="$hitPN"/>, Sentence <xsl:value-of select="$hitPosOfS"/></a> / <a href="?{$documentValue}&pn={$hitPN + 1}&sn=0&{$modeValue}&query-type={$queryType}{$queryValueEscaped2}&query-result-pn={$queryResultPN}#sn0">Page <xsl:value-of select="$hitPN + 1"/>, continuation of the sentence</a> + <a href="?{$documentValue}&pn={$hitPN}&{$modeValue}&query-type={$queryType}{$queryValueEscaped2}&query-result-pn={$queryResultPN}&highlightElement={$hitType}&highlightElementPos={$hitPos}#s{$hitPos}">Page <xsl:value-of select="$hitPN"/>, Sentence <xsl:value-of select="$hitPos"/></a> / <a href="?{$documentValue}&pn={$hitPN + 1}&{$modeValue}&query-type={$queryType}{$queryValueEscaped2}&query-result-pn={$queryResultPN}#s0">Page <xsl:value-of select="$hitPN + 1"/>, continuation of the sentence</a> </xsl:otherwise> </xsl:choose> :<br/> <!-- Highlight the query terms in each hit sentence and clip the result --> - <xsl:sequence select="text:highlight(s, $ftQueryTerms, $ftQueryHighlightWords, 'true')"/> + <xsl:sequence select="text:highlight($hitString, $ftQueryTerms, $ftQueryHighlightWords, 'true')"/> </td> </tr> </xsl:for-each> @@ -659,6 +668,7 @@ <xsl:template match="element()|comment()|processing-instruction()" mode="xml"> <xsl:variable name="elementName" select="name()"/> + <xsl:variable name="countPrecedingElemsStr" select="concat('count(preceding::', $elementName, '[. >> $p1]) + 1')"/> <xsl:variable name="elementPresentation"> <xsl:choose> <xsl:when test="element() = node() or text() != '' or self::comment() or self::processing-instruction()"> @@ -679,30 +689,24 @@ </xsl:otherwise> </xsl:choose> </xsl:variable> - <xsl:variable name="actualSN"> + <xsl:variable name="currentHighlightElementPos"> <xsl:choose> - <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when> - <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> + <xsl:when test="($highlightElement = 's' or $highlightElement = '') and . = $firstSentence and ($topPB >> .)">0</xsl:when> + <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:value-of select="saxon:evaluate($countPrecedingElemsStr, $topPB)"/></xsl:when> + <xsl:otherwise><xsl:value-of select="saxon:evaluate($countPrecedingElemsStr, $topPB)"/></xsl:otherwise> </xsl:choose> </xsl:variable> - <xsl:choose> - <!-- Show the sentence in color light grey if it is given as sn --> - <xsl:when test="$elementName = 's' and $sn >= 0 and $sn = $actualSN"> - <ul class="xml element highlight"> - <a name="sn{$actualSN}"></a><xsl:sequence select="$elementPresentation"/> - </ul> - </xsl:when> - <xsl:when test="$elementName = 's' and $sn != $actualSN"> - <ul class="xml element"> - <a name="sn{$actualSN}"></a><xsl:sequence select="$elementPresentation"/> - </ul> - </xsl:when> - <xsl:otherwise> - <ul class="xml element"> - <xsl:sequence select="$elementPresentation"/> - </ul> - </xsl:otherwise> - </xsl:choose> + <xsl:variable name="class"> + <xsl:choose> + <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> + <xsl:when test="$elementName = $highlightElement and $highlightElementPos >= 0 and $highlightElementPos != $currentHighlightElementPos"><xsl:value-of select="'xml element'"/></xsl:when> + <xsl:otherwise><xsl:value-of select="'xml element'"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + <!-- Show the sentence in color light grey if it is given as highlightElementPos --> + <ul class="{$class}" id="{$elementName}{$currentHighlightElementPos}"> + <xsl:sequence select="$elementPresentation"/> + </ul> </xsl:template> <xsl:template match="attribute()" mode="xml"> @@ -718,18 +722,29 @@ <!-- If ft-query is set then highlight all term occurrences in each little text piece for the fulltext query --> <xsl:template match="text()" mode="xml"> - <xsl:variable name="parentS" select="./ancestor::s"/> - <xsl:variable name="actualSN"> + <xsl:variable name="ancestorStr" select="concat('./ancestor::', $highlightElement)"/> + <xsl:variable name="highlightElementAncestor"> <xsl:choose> - <xsl:when test="$parentS = $firstSentence and ($topPB >> $parentS)">0</xsl:when> - <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> + <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:sequence select="./ancestor::s"/></xsl:when> + <xsl:otherwise><xsl:sequence select="saxon:evaluate($ancestorStr)"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="highlightElementAncestorType" select="name($highlightElementAncestor/*[1])"/> + <xsl:variable name="countPrecedingElemsStr" select="concat('count(preceding::', $highlightElement, '[. >> $p1]) + 1')"/> + <xsl:variable name="currentHighlightElementPos"> + <xsl:choose> + <xsl:when test="($highlightElement = 's' or $highlightElement = '') and $highlightElementAncestor = $firstSentence and ($topPB >> $highlightElementAncestor)">0</xsl:when> + <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:value-of select="saxon:evaluate($countPrecedingElemsStr, $topPB)"/></xsl:when> + <xsl:otherwise><xsl:value-of select="saxon:evaluate($countPrecedingElemsStr, $topPB)"/></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> - <xsl:when test="$ftQueryMode != 'false' and $sn >= 0 and $sn = $actualSN"> + <xsl:when test="$ftQueryMode != 'false' and $highlightElementAncestorType = $highlightElement and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"> <xsl:sequence select="text:highlight(string(.), $ftQueryTerms, $ftQueryHighlightWords, 'false')"/> </xsl:when> - <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise> + <xsl:otherwise> + <xsl:value-of select="."/> + </xsl:otherwise> </xsl:choose> </xsl:template> @@ -866,7 +881,26 @@ </xsl:template> <xsl:template match="head" mode="text"> - <p class="bf center"><xsl:apply-templates mode="text"/></p> + <xsl:variable name="currentHighlightElementPos"> + <xsl:choose> + <xsl:when test="$highlightElement = 'head'"><xsl:value-of select="count(preceding::head[. >> $topPB]) + 1"/></xsl:when> + <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="class"> + <xsl:choose> + <xsl:when test="not(empty(@style)) and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"><xsl:value-of select="concat('head highlight bf ', @style)"/></xsl:when> + <xsl:when test="empty(@style) and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"><xsl:value-of select="'head highlight bf'"/></xsl:when> + <xsl:otherwise><xsl:value-of select="'head bf'"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + <p> + <span> + <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute> + <xsl:attribute name="id"><xsl:value-of select="concat('head', $currentHighlightElementPos)"/></xsl:attribute> + <xsl:apply-templates mode="text"/> + </span> + </p> </xsl:template> <!-- TEI: segmentation --> @@ -1128,20 +1162,35 @@ </xsl:template> <xsl:template match="p" mode="text"> + <xsl:variable name="currentHighlightElementPos"> + <xsl:choose> + <xsl:when test="$highlightElement = 'p'"><xsl:value-of select="count(preceding::p[. >> $topPB]) + 1"/></xsl:when> + <xsl:otherwise><xsl:value-of select="0"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> <xsl:variable name="style" select="@style"/> + <xsl:variable name="class"> + <xsl:choose> + <xsl:when test="not(empty(@style)) and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"><xsl:value-of select="concat('p highlight ', @style)"/></xsl:when> + <xsl:when test="empty(@style) and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"><xsl:value-of select="'p highlight'"/></xsl:when> + <xsl:otherwise><xsl:value-of select="'p'"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> <xsl:choose> <xsl:when test="not(empty($style))"> <div> - <xsl:attribute name="class"><xsl:value-of select="'p'"/></xsl:attribute> + <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute> <span> - <xsl:attribute name="class"><xsl:value-of select="$style"/></xsl:attribute> + <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute> + <xsl:attribute name="id"><xsl:value-of select="concat('p', $currentHighlightElementPos)"/></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:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute> + <xsl:attribute name="id"><xsl:value-of select="concat('p', $currentHighlightElementPos)"/></xsl:attribute> <xsl:apply-templates mode="text"/> </div> </xsl:otherwise> @@ -1164,7 +1213,17 @@ </xsl:template> <xsl:template match="expan" mode="text"> - <xsl:apply-templates 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"> @@ -1226,7 +1285,7 @@ <xsl:otherwise> <xsl:choose> <xsl:when test="not(empty(w))"> - <a class="textPollux" href="interface/lt/wordInfo.xql?language={w/@lang}&word={w/@form}&output=html"><xsl:value-of select="$restChars"/></a> + <a class="textPollux" href="interface/lt/wordInfo.xql?language={w/@lang}&display={$text}&word={w/@form}&output=html"><xsl:value-of select="$restChars"/></a> </xsl:when> <xsl:otherwise><xsl:value-of select="$restChars"/></xsl:otherwise> </xsl:choose> @@ -1237,6 +1296,9 @@ <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 $length = 1"> + <span class="sc"><xsl:value-of select="$firstChar"/></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> @@ -1244,7 +1306,7 @@ <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"/> + <span class="sc"><xsl:apply-templates mode="text"/></span> </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> @@ -1273,37 +1335,107 @@ </xsl:template> <xsl:template match="q" mode="text"> - <span class="q"><xsl:apply-templates mode="text"/></span> + <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"> - <div class="quote"><xsl:apply-templates mode="text"/></div> + <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"> - <div class="blockquote"><xsl:apply-templates mode="text"/></div> + <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"> - <div class="set-off"><xsl:apply-templates mode="text"/></div> + <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"> - <span class="reg"> - <xsl:apply-templates mode="text"/> - </span> + <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:variable name="type" select="@type"/> - <span class="var"> - <xsl:attribute name="class"><xsl:value-of select="concat('var ', $type)"/></xsl:attribute> - <xsl:apply-templates mode="text"/> - </span> + <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"> - <span class="num"><xsl:apply-templates mode="text"/></span> + <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"> @@ -1527,27 +1659,31 @@ <!-- textPollux links --> <xsl:template match="w" mode="text"> <xsl:variable name="wordLanguage" select="@lang"/> - <xsl:variable name="form" select="@form"/> + <xsl:variable name="form" select="encode-for-uri(@form)"/> + <xsl:variable name="displayWord"><xsl:apply-templates mode="text"/></xsl:variable> + <xsl:variable name="displayWordUrlEncoded" select="encode-for-uri($displayWord)"/> <xsl:choose> <xsl:when test="not(empty(anchor))"> <xsl:for-each select="node()"> + <xsl:variable name="dispWord"><xsl:apply-templates mode="text" select="."/></xsl:variable> + <xsl:variable name="dispWordUrlEncoded" select="encode-for-uri($dispWord)"/> <xsl:choose> <xsl:when test=". instance of text()"> <a class="textPollux"> - <xsl:attribute name="href"><xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&word=', $form, '&output=html')"/></xsl:attribute> - <xsl:apply-templates mode="text" select="."/> + <xsl:attribute name="href"><xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&display=', $dispWordUrlEncoded, '&word=', $form, '&output=html')"/></xsl:attribute> + <xsl:sequence select="$dispWord"/> </a> </xsl:when> <xsl:otherwise> - <xsl:apply-templates mode="text" select="."/> + <xsl:sequence select="$dispWord"/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:when> <xsl:otherwise> <a class="textPollux"> - <xsl:attribute name="href"><xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&word=', $form, '&output=html')"/></xsl:attribute> - <xsl:apply-templates mode="text"/> + <xsl:attribute name="href"><xsl:value-of select="concat('interface/lt/wordInfo.xql?language=', $wordLanguage, '&display=', $displayWordUrlEncoded, '&word=', $form, '&output=html')"/></xsl:attribute> + <xsl:sequence select="$displayWord"/> </a> </xsl:otherwise> </xsl:choose> @@ -1555,17 +1691,16 @@ <xsl:template match="s" mode="text"> <xsl:variable name="style" select="@style"/> - <xsl:variable name="actualSN"> + <xsl:variable name="currentSN"> <xsl:choose> <xsl:when test=". = $firstSentence and ($topPB >> .)">0</xsl:when> <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> </xsl:choose> </xsl:variable> - <a name="sn{$actualSN}"></a> <xsl:choose> - <!-- Show the sentence in color light grey if it is given as sn --> - <xsl:when test="$sn >= 0 and $sn = $actualSN"> - <span class="s highlight"> + <!-- Show the sentence in color light grey if it is given as sn or highlightElem --> + <xsl:when test="($sn >= 0 and $sn = $currentSN) or ($highlightElement = 's' and $highlightElementPos >= 0 and $highlightElementPos = $currentSN)"> + <span class="s highlight" id="s{$currentSN}"> <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if> <xsl:choose> <xsl:when test="empty(@style)"> @@ -1578,7 +1713,7 @@ </span> </xsl:when> <xsl:otherwise> - <span class="s"> + <span class="s" id="s{$currentSN}"> <xsl:if test="not(empty(@xmlNodeId))"><xsl:attribute name="xmlNodeId"><xsl:value-of select="@xmlNodeId"/></xsl:attribute></xsl:if> <xsl:choose> <xsl:when test="empty(@style)"> @@ -1595,20 +1730,29 @@ <!-- If ft-query is set then highlight all term occurrences in each little text piece for the fulltext query --> <xsl:template match="text()" mode="text"> - <xsl:variable name="parentS" select="./ancestor::s"/> - <xsl:variable name="actualSN"> + <xsl:variable name="ancestorStr" select="concat('./ancestor::', $highlightElement)"/> + <xsl:variable name="highlightElementAncestor"> <xsl:choose> - <xsl:when test="$parentS = $firstSentence and ($topPB >> $parentS)">0</xsl:when> - <xsl:otherwise><xsl:value-of select="count(preceding::s[. >> $topPB]) + 1"/></xsl:otherwise> + <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:sequence select="./ancestor::s"/></xsl:when> + <xsl:otherwise><xsl:sequence select="saxon:evaluate($ancestorStr)"/></xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="highlightElementAncestorType" select="name($highlightElementAncestor/*[1])"/> + <xsl:variable name="countPrecedingElemsStr" select="concat('count(preceding::', $highlightElement, '[. >> $p1]) + 1')"/> + <xsl:variable name="currentHighlightElementPos"> + <xsl:choose> + <xsl:when test="($highlightElement = 's' or $highlightElement = '') and $highlightElementAncestor = $firstSentence and ($topPB >> $highlightElementAncestor)">0</xsl:when> + <xsl:when test="$highlightElement = 's' or $highlightElement = ''"><xsl:value-of select="saxon:evaluate($countPrecedingElemsStr, $topPB)"/></xsl:when> + <xsl:otherwise><xsl:value-of select="saxon:evaluate($countPrecedingElemsStr, $topPB)"/></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> - <xsl:when test="$ftQueryMode != 'false' and $sn >= 0 and $sn = $actualSN"> - <xsl:sequence select="text:highlight(string(.), $ftQueryTerms, $ftQueryHighlightWords, 'false')"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="."/> - </xsl:otherwise> + <xsl:when test="$ftQueryMode != 'false' and $highlightElementAncestorType = $highlightElement and $highlightElementPos >= 0 and $highlightElementPos = $currentHighlightElementPos"> + <xsl:sequence select="text:highlight(string(.), $ftQueryTerms, $ftQueryHighlightWords, 'false')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="."/> + </xsl:otherwise> </xsl:choose> </xsl:template>