root/main/branches/64_bit_Greenstone/greenstone3/web/interfaces/default-client-xslt/transform/querytools.xsl @ 24007

Revision 24007, 8.0 KB (checked in by sjm84, 8 years ago)

Updating this branch to match the latest Greenstone3 changes

Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<xsl:stylesheet version="1.0"
3  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4  xmlns:java="http://xml.apache.org/xslt/java"
5  xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6  extension-element-prefixes="java util"
7  exclude-result-prefixes="java util">
8
9  <!-- have changed this so it uses service hitsPerPage and startPage if the service description has a param called hitsPerPage,  otherwise uses interface ones -->
10  <xsl:template name="resultNavigation">
11    <xsl:param name="collName"/>
12    <div class="resultnavigation"> 
13      <!-- hits type -->
14      <xsl:variable name='ht'>
15    <xsl:choose>
16      <xsl:when test="/page/pageResponse/service/paramList/param[@name='hitsPerPage']">s</xsl:when>
17      <xsl:otherwise>i</xsl:otherwise>
18    </xsl:choose>
19      </xsl:variable>
20     
21      <xsl:variable name="param-list" select="/page/pageRequest/paramList"/>
22      <!-- hits per page -->
23      <xsl:variable name="hpp">
24    <xsl:choose>
25      <xsl:when test="$ht='s'"><xsl:value-of select="$param-list/param[@name='s1.hitsPerPage']/@value"/></xsl:when>
26      <xsl:when test="$param-list/param[@name='hitsPerPage']"><xsl:value-of select="$param-list/param[@name='hitsPerPage']/@value"/></xsl:when>
27      <xsl:otherwise>20</xsl:otherwise>
28    </xsl:choose>
29      </xsl:variable>
30      <!-- total docs - this may be in numDocsMatched or numDocsReturned metadata -->
31      <xsl:variable name="td">
32    <xsl:choose>
33      <xsl:when test="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']">
34        <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']"/>
35      </xsl:when>
36      <xsl:when test="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']">
37        <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']"/>
38      </xsl:when>
39      <xsl:otherwise> <!-- this is just a fall back - should always have the metadata -->
40        <xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/>
41      </xsl:otherwise> 
42    </xsl:choose>
43      </xsl:variable>
44
45      <!-- only continue if hpp != -1 and td > hpp -->
46      <xsl:if test="not($hpp=-1) and $td &gt; $hpp">
47    <!-- start page -->
48    <xsl:variable name="here">
49      <xsl:choose>
50        <xsl:when test="$ht='s'"><xsl:value-of select="$param-list/param[@name='s1.startPage']/@value"/></xsl:when>
51        <xsl:when test="$param-list/param[@name='startPage']"><xsl:value-of select="$param-list/param[@name='startPage']/@value"/></xsl:when>
52        <xsl:otherwise>1</xsl:otherwise>
53      </xsl:choose>
54    </xsl:variable>
55    <xsl:variable name="sa" select="/page/pageRequest/@subaction"/>
56    <xsl:variable name="service" select="$param-list/param[@name='s']/@value"/>
57    <xsl:variable name="prev" select="$here - 1"/>
58    <xsl:variable name="next" select="$here + 1"/>
59    <xsl:variable name="page-param"><xsl:if test="$ht='s'">s1.</xsl:if>startPage</xsl:variable>
60   
61    <div>   
62      <div>
63        <xsl:if test="$here &gt; 1"><a href="{$library_name}?a=q&amp;sa={$sa}&amp;c={$collName}&amp;s={$service}&amp;rt=rd&amp;{$page-param}={$prev}"><img src="interfaces/default/images/less.gif" width='30' height='16' border='0' align='top'/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.matches')"/><xsl:text> </xsl:text><xsl:value-of select="number(($prev - 1)*$hpp + 1)"/> - <xsl:value-of select="number(($prev * $hpp))"/></a></xsl:if>
64       
65       
66        <xsl:if test="(($here * $hpp) + 1)  &lt; $td">
67          <xsl:variable name='m' select="number($next * $hpp)"/>
68          <xsl:variable name='mm'><xsl:choose><xsl:when test="$m &lt; $td"><xsl:value-of select='$m'/></xsl:when><xsl:otherwise><xsl:value-of select='$td'/></xsl:otherwise></xsl:choose></xsl:variable>
69          <a href="{$library_name}?a=q&amp;sa={$sa}&amp;c={$collName}&amp;s={$service}&amp;rt=rd&amp;{$page-param}={$next}"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.matches')"/><xsl:text> </xsl:text><xsl:value-of select="number(($next - 1)*$hpp + 1)"/> - <xsl:value-of select="$mm"/><img src="interfaces/default/images/more.gif" width='30' height='16' border='0' align='top'/></a></xsl:if></div>
70    </div>
71      </xsl:if>
72    </div>
73  </xsl:template>
74 
75  <xsl:template name="matchDocs">
76    <!-- If the number of matching documents is known, display it -->
77    <div id="matchdocs">
78      <xsl:variable name="numDocsMatched" select="metadataList/metadata[@name='numDocsMatched']"/>
79      <xsl:variable name="numDocsReturned" select="metadataList/metadata[@name='numDocsReturned']"/>
80      <xsl:choose>
81    <xsl:when test="$numDocsMatched='0' or $numDocsReturned='0'">
82      <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.nodocsmatch')"/>
83    </xsl:when>
84    <xsl:when test="$numDocsMatched='1' or $numDocsReturned='1'">
85      <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.onedocsmatch')"/>
86    </xsl:when>
87    <xsl:when test="$numDocsMatched">
88      <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.manydocsmatch', $numDocsMatched)"/>
89      <xsl:if test="$numDocsReturned"> (<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.docsreturned', $numDocsReturned)"/>)</xsl:if>
90    </xsl:when>
91    <xsl:when test="$numDocsReturned">
92      <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.atleastdocsmatch', $numDocsReturned)"/>
93    </xsl:when>
94      </xsl:choose>
95    </div>
96  </xsl:template>
97
98  <!-- paging is now done by the query action, so here we just print out all the docs that we have -->
99  <xsl:template name="resultList">
100    <xsl:param name="collName"/>
101    <ul id="resultlist">
102      <xsl:for-each select="documentNodeList/documentNode">
103    <li><table>
104        <xsl:call-template name="documentNodeWrapper">
105          <xsl:with-param name="collName" select="$collName"/>
106          <xsl:with-param name="serviceName" select="/page/pageResponse/service/@name"/>
107        </xsl:call-template>
108      </table>
109    </li>       
110      </xsl:for-each> 
111    </ul>
112  </xsl:template>
113 
114  <!-- this is a wrapper node, which the interface can use to add stuff into the query results that isn't part of and doesn't depend on the documentNode template which may come from the collection -->
115  <xsl:template name="documentNodeWrapper">
116    <xsl:param name="collName"/>
117    <xsl:param name="serviceName"/>
118    <xsl:variable name="berrybasketswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='berrybasket']/@value"/></xsl:variable>
119    <!--<xsl:if test="$berryBaskets = 'true'">-->
120    <xsl:if test="$berrybasketswitch = 'on'">
121      <xsl:call-template name="addBerry">
122    <xsl:with-param name="collName" select="$collName"/>
123      </xsl:call-template>
124    </xsl:if>
125    <xsl:apply-templates select=".">
126      <xsl:with-param name="collName" select="$collName"/>
127      <xsl:with-param name="serviceName" select="$serviceName"/>
128    </xsl:apply-templates>
129  </xsl:template>
130
131 
132  <!-- the default doc node template for the query results -->
133  <!-- eventually shouldn't need sib arg here -->
134  <xsl:template match="documentNode">
135    <xsl:param name="collName"/>
136    <xsl:param name="serviceName"/>
137    <a><xsl:attribute name="href"><xsl:value-of select='$library_name'/>?a=d&amp;c=<xsl:value-of select='$collName'/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="@nodeType='leaf'">&amp;sib=1</xsl:if>&amp;dt=<xsl:value-of select='@docType'/>&amp;p.a=q&amp;&amp;p.sa=<xsl:value-of select="/page/pageRequest/@subaction"/>&amp;p.s=<xsl:value-of select="$serviceName"/></xsl:attribute>
138      <xsl:apply-templates select="." mode="displayNodeIcon"/>
139    </a>
140    <span><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></span>
141  </xsl:template>
142
143  <xsl:template name="termInfo">
144    <div class="terminfo">
145      <xsl:if test="count(termList/term) > 0">
146    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'query.wordcount')"/>
147    <xsl:for-each select="termList/term">
148      <xsl:if test="position() > 1">, </xsl:if>
149      <xsl:value-of select="@name"/>: <xsl:value-of select="@freq"/>
150    </xsl:for-each>
151      </xsl:if>
152    </div>
153  </xsl:template>
154
155</xsl:stylesheet>
156
157
Note: See TracBrowser for help on using the browser.