source: main/trunk/greenstone3/web/interfaces/default/transform/querytools.xsl@ 23779

Last change on this file since 23779 was 23779, checked in by davidb, 13 years ago

Two new interfaces - 'default' now tries to use the client's XSLT capabilities of the web browser, falling back to the 'traditional' interface if this fails.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
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 extension-element-prefixes="java"
6 exclude-result-prefixes="java">
7
8 <!-- have changed this so it uses service hitsPerPage and startPage if the service description has a param called hitsPerPage, otherwise uses interface ones -->
9 <xsl:template name="resultNavigation">
10 <xsl:param name="collName"/>
11 <div class="resultnavigation">
12 <!-- hits type -->
13 <xsl:variable name='ht'>
14 <xsl:choose>
15 <xsl:when test="/page/pageResponse/service/paramList/param[@name='hitsPerPage']">s</xsl:when>
16 <xsl:otherwise>i</xsl:otherwise>
17 </xsl:choose>
18 </xsl:variable>
19
20 <xsl:variable name="param-list" select="/page/pageRequest/paramList"/>
21 <!-- hits per page -->
22 <xsl:variable name="hpp">
23 <xsl:choose>
24 <xsl:when test="$ht='s'"><xsl:value-of select="$param-list/param[@name='s1.hitsPerPage']/@value"/></xsl:when>
25 <xsl:when test="$param-list/param[@name='hitsPerPage']"><xsl:value-of select="$param-list/param[@name='hitsPerPage']/@value"/></xsl:when>
26 <xsl:otherwise>20</xsl:otherwise>
27 </xsl:choose>
28 </xsl:variable>
29 <!-- total docs - this may be in numDocsMatched or numDocsReturned metadata -->
30 <xsl:variable name="td">
31 <xsl:choose>
32 <xsl:when test="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']">
33 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']"/>
34 </xsl:when>
35 <xsl:when test="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']">
36 <xsl:value-of select="/page/pageResponse/metadataList/metadata[@name='numDocsMatched']"/>
37 </xsl:when>
38 <xsl:otherwise> <!-- this is just a fall back - should always have the metadata -->
39 <xsl:value-of select="count(/page/pageResponse/documentNodeList/documentNode)"/>
40 </xsl:otherwise>
41 </xsl:choose>
42 </xsl:variable>
43
44 <!-- only continue if hpp != -1 and td > hpp -->
45 <xsl:if test="not($hpp=-1) and $td &gt; $hpp">
46 <!-- start page -->
47 <xsl:variable name="here">
48 <xsl:choose>
49 <xsl:when test="$ht='s'"><xsl:value-of select="$param-list/param[@name='s1.startPage']/@value"/></xsl:when>
50 <xsl:when test="$param-list/param[@name='startPage']"><xsl:value-of select="$param-list/param[@name='startPage']/@value"/></xsl:when>
51 <xsl:otherwise>1</xsl:otherwise>
52 </xsl:choose>
53 </xsl:variable>
54 <xsl:variable name="sa" select="/page/pageRequest/@subaction"/>
55 <xsl:variable name="service" select="$param-list/param[@name='s']/@value"/>
56 <xsl:variable name="prev" select="$here - 1"/>
57 <xsl:variable name="next" select="$here + 1"/>
58 <xsl:variable name="page-param"><xsl:if test="$ht='s'">s1.</xsl:if>startPage</xsl:variable>
59
60 <div>
61 <div>
62 <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'/><span class="getTextFor query.matches"></span><xsl:text> </xsl:text><xsl:value-of select="number(($prev - 1)*$hpp + 1)"/> - <xsl:value-of select="number(($prev * $hpp))"/></a></xsl:if>
63
64
65 <xsl:if test="(($here * $hpp) + 1) &lt; $td">
66 <xsl:variable name='m' select="number($next * $hpp)"/>
67 <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>
68 <a href="{$library_name}?a=q&amp;sa={$sa}&amp;c={$collName}&amp;s={$service}&amp;rt=rd&amp;{$page-param}={$next}"><span class="getTextFor query.matches"></span><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>
69 </div>
70 </xsl:if>
71 </div>
72 </xsl:template>
73
74 <xsl:template name="matchDocs">
75 <!-- If the number of matching documents is known, display it -->
76 <div id="matchdocs">
77 <xsl:variable name="numDocsMatched" select="metadataList/metadata[@name='numDocsMatched']"/>
78 <xsl:variable name="numDocsReturned" select="metadataList/metadata[@name='numDocsReturned']"/>
79 <xsl:choose>
80 <xsl:when test="$numDocsMatched='0' or $numDocsReturned='0'">
81 <span class="getTextFor query.nodocsmatch"></span>
82 </xsl:when>
83 <xsl:when test="$numDocsMatched='1' or $numDocsReturned='1'">
84 <span class="getTextFor query.onedocsmatch"></span>
85 </xsl:when>
86 <xsl:when test="$numDocsMatched">
87 <span><xsl:attribute name="class"><xsl:value-of select="concat('getTextFor null this.innerText.query.manydocsmatch|', $numDocsMatched)"/></xsl:attribute></span>
88 <xsl:if test="$numDocsReturned"> (<span><xsl:attribute name="class"><xsl:value-of select="concat('getTextFor null this.innerText.query.docsreturned|', $numDocsReturned)" /></xsl:attribute></span>)</xsl:if>
89 </xsl:when>
90 <xsl:when test="$numDocsReturned">
91 <span><xsl:attribute name="class"><xsl:value-of select="concat('getTextFor null this.innerText.query.atleastdocsmatch|', $numDocsReturned)" /></xsl:attribute></span>
92 </xsl:when>
93 </xsl:choose>
94 </div>
95 </xsl:template>
96
97 <!-- paging is now done by the query action, so here we just print out all the docs that we have -->
98 <xsl:template name="resultList">
99 <xsl:param name="collName"/>
100 <ul id="resultlist">
101 <xsl:for-each select="documentNodeList/documentNode">
102 <li><table>
103 <xsl:call-template name="documentNodeWrapper">
104 <xsl:with-param name="collName" select="$collName"/>
105 <xsl:with-param name="serviceName" select="/page/pageResponse/service/@name"/>
106 </xsl:call-template>
107 </table>
108 </li>
109 </xsl:for-each>
110 </ul>
111 </xsl:template>
112
113 <!-- 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 -->
114 <xsl:template name="documentNodeWrapper">
115 <xsl:param name="collName"/>
116 <xsl:param name="serviceName"/>
117 <xsl:variable name="berrybasketswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='berrybasket']/@value"/></xsl:variable>
118 <!--<xsl:if test="$berryBaskets = 'true'">-->
119 <xsl:if test="$berrybasketswitch = 'on'">
120 <xsl:call-template name="addBerry">
121 <xsl:with-param name="collName" select="$collName"/>
122 </xsl:call-template>
123 </xsl:if>
124 <xsl:apply-templates select=".">
125 <xsl:with-param name="collName" select="$collName"/>
126 <xsl:with-param name="serviceName" select="$serviceName"/>
127 </xsl:apply-templates>
128 </xsl:template>
129
130
131 <!-- the default doc node template for the query results -->
132 <!-- eventually shouldn't need sib arg here -->
133 <xsl:template match="documentNode">
134 <xsl:param name="collName"/>
135 <xsl:param name="serviceName"/>
136 <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>
137 <xsl:apply-templates select="." mode="displayNodeIcon"/><xsl:text>sample</xsl:text>
138 </a>
139 <span><xsl:text>Testing</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></span>
140 </xsl:template>
141
142 <xsl:template name="termInfo">
143 <div class="terminfo">
144 <xsl:if test="count(termList/term) > 0">
145 <span class="getTextFor query.wordcount">&amp;nbsp;</span>
146 <xsl:for-each select="termList/term">
147 <xsl:if test="position() > 1">, </xsl:if>
148 <xsl:value-of select="@name"/>: <xsl:value-of select="@freq"/>
149 </xsl:for-each>
150 </xsl:if>
151 </div>
152 </xsl:template>
153
154</xsl:stylesheet>
155
156
Note: See TracBrowser for help on using the repository browser.