source: main/branches/64_bit_Greenstone/greenstone3/web/interfaces/oran/transform/pages/query.xsl@ 24007

Last change on this file since 24007 was 24007, checked in by sjm84, 13 years ago

Updating this branch to match the latest Greenstone3 changes

File size: 11.2 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 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 extension-element-prefixes="java util"
8 exclude-result-prefixes="java util">
9
10 <!-- use the 'main' layout -->
11 <xsl:include href="layouts/main.xsl"/>
12
13 <!-- set page title -->
14 <xsl:template name="pageTitle"><gslib:serviceName/></xsl:template>
15
16 <!-- set page breadcrumbs -->
17 <xsl:template name="breadcrumbs"> <gslib:siteLink/><gslib:rightArrow/><xsl:if test="/page/pageResponse/collection"> <gslib:collectionNameLinked/><gslib:rightArrow/></xsl:if></xsl:template>
18
19 <!-- the page content -->
20 <xsl:template match="/page">
21 <xsl:choose>
22 <xsl:when test="not(pageResponse/documentNodeList)">
23 <xsl:for-each select="pageResponse/service">
24 <form name="QueryForm" method="get" action="{$library_name}">
25 <div>
26 <input type="hidden" name="a" value="q"/>
27 <input type="hidden" name="sa"><xsl:attribute name="value"><xsl:value-of select="/page/pageRequest/@subaction"/></xsl:attribute></input>
28 <input type="hidden" name="rt" value="rd"/>
29 <input type="hidden" name="s" value="{@name}"/>
30 <input type="hidden" name="c" value="{$collName}"/>
31 <xsl:if test="not(paramList/param[@name='startPage'])">
32 <input type="hidden" name="startPage" value="1"/>
33 </xsl:if>
34
35 <xsl:variable name="ns">s1.</xsl:variable>
36 <xsl:for-each select="paramList/param">
37 <xsl:choose>
38 <xsl:when test="@name='case' or @name='stem' or @name='accent'">
39 </xsl:when>
40 <xsl:when test="@type='multi'">
41 <xsl:apply-templates select="."><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
42 </xsl:when>
43 <xsl:when test="@name = 'sortBy' or @name = 'maxDocs'"></xsl:when>
44 <xsl:otherwise>
45 <xsl:variable name="pvalue"><xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates></xsl:variable>
46 <div class="paramLabel"><xsl:value-of select="displayItem[@name='name']"/></div>
47 <div class="paramValue">
48 <xsl:apply-templates select=".">
49 <xsl:with-param name="default" select="$pvalue"/>
50 <xsl:with-param name="ns" select="$ns"/>
51 </xsl:apply-templates>
52 </div>
53 <br class="clear"/>
54 </xsl:otherwise>
55 </xsl:choose>
56 </xsl:for-each>
57
58 <br/>
59
60 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="displayItem[@name='submit']"/></xsl:attribute></input>
61
62 </div>
63 </form>
64 </xsl:for-each>
65
66 </xsl:when>
67
68 <xsl:otherwise>
69 <p class="termList">
70 <xsl:choose>
71 <xsl:when test="count(/page/pageResponse/termList/term) &lt; 3">
72 <xsl:for-each select="/page/pageResponse/termList/term">
73 <span style="font-style:italic;"><xsl:value-of select="@name"/></span> occurs <xsl:value-of select="@freq"/> times in <xsl:value-of select="@numDocsMatch"/> document(s) <br />
74 </xsl:for-each>
75 </xsl:when>
76 <xsl:otherwise>
77 <xsl:for-each select="/page/pageResponse/termList/term">
78 <span style="font-style:italic;"><xsl:value-of select="@name"/></span> (<xsl:value-of select="@freq"/>);
79 </xsl:for-each>
80 </xsl:otherwise>
81 </xsl:choose>
82 </p>
83
84 <ul id="results">
85 <xsl:for-each select="pageResponse/documentNodeList/documentNode">
86 <li class="document">
87 <a>
88 <xsl:choose>
89 <xsl:when test="/page/pageResponse/collection/@name">
90 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=q&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;hl=on&amp;ed=1#<xsl:value-of select="@nodeID"/></xsl:attribute>
91 </xsl:when>
92 <xsl:when test="@collection">
93 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="@collection"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=q&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;hl=on&amp;ed=1#<xsl:value-of select="@nodeID"/></xsl:attribute>
94 </xsl:when>
95 </xsl:choose>
96
97 <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
98 </a>
99
100 <!-- If this is results from a cross collection search then add a link to the collection that it is from -->
101 <xsl:if test="@collection">
102 (<a style="background-image:none; padding:3px;">
103 <xsl:attribute name="href">
104 <xsl:value-of select="$library_name"/>?a=p&amp;sa=about&amp;c=<xsl:value-of select="@collection"/>
105 </xsl:attribute>
106 <xsl:value-of select="@collection"/>
107 </a>)
108 </xsl:if>
109 <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
110 </li>
111 </xsl:for-each>
112 </ul>
113 </xsl:otherwise>
114
115 </xsl:choose>
116
117 </xsl:template>
118
119
120 <!-- puts all the params into a=p&p=h type form - need to change this if use
121 multi params -->
122 <xsl:template match="paramList" mode="cgi">
123 <xsl:param name="ns">s1.</xsl:param>
124 <xsl:for-each select="param">
125 <xsl:variable name='pname' select="@name"/>
126 <xsl:text>&amp;</xsl:text><xsl:value-of select="$ns"/><xsl:value-of select="@name"/>=<xsl:apply-templates select="." mode="calculate-default"><xsl:with-param name='ns' select='$ns'/></xsl:apply-templates>
127 </xsl:for-each>
128 </xsl:template>
129
130 <xsl:template match="param" mode="calculate-default">
131 <xsl:param name="ns">s1.</xsl:param>
132 <xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
133 <xsl:choose>
134 <xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
135 <xsl:choose>
136 <xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
137 <xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
138 <xsl:value-of select="@value"/>,
139 </xsl:for-each>
140 </xsl:when>
141 <xsl:otherwise>
142 <xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
143 </xsl:otherwise>
144 </xsl:choose>
145 </xsl:when>
146 <xsl:otherwise>
147 <xsl:value-of select="@default"/>
148 </xsl:otherwise>
149 </xsl:choose>
150 </xsl:template>
151
152 <!-- invisible params - used by other stuff. in the query form, we set to the default -->
153 <xsl:template match="param[@type='invisible']">
154 <xsl:param name="ns">s1.</xsl:param>
155 <input type='hidden' name='{$ns}{@name}' value='{@default}'/>
156 </xsl:template>
157
158 <!-- boolean params -->
159 <xsl:template match="param[@type='boolean']">
160 <xsl:param name="ns">s1.</xsl:param>
161 <xsl:param name="default"/>
162 <select name='{$ns}{@name}'>
163 <option value="0"><xsl:if test="$default='0'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="option[@name='0']/displayItem[@name='name']"/></option>
164 <option value="1"><xsl:if test="$default='1'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="option[@name='1']/displayItem[@name='name']"/></option>
165 </select>
166 </xsl:template>
167
168 <!-- integer params -->
169 <xsl:template match="param[@type='integer']">
170 <xsl:param name="ns">s1.</xsl:param>
171 <xsl:param name="default"/>
172 <input type="text" name="{$ns}{@name}" size="3" value="{$default}"/>
173 </xsl:template>
174
175 <!-- single selection enum params -->
176 <xsl:template match="param[@type='enum_single']">
177 <xsl:param name="ns">s1.</xsl:param>
178 <xsl:param name="default"/>
179 <xsl:choose>
180 <xsl:when test="count(option) = 1">
181 <xsl:value-of select="option/displayItem[@name='name']"/>
182 <input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of select='option/@name'/></xsl:attribute></input>
183 </xsl:when>
184 <xsl:otherwise>
185 <select name="{$ns}{@name}">
186 <xsl:for-each select="option">
187 <option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
188 </xsl:for-each>
189 </select>
190 </xsl:otherwise>
191 </xsl:choose>
192 </xsl:template>
193
194
195 <!-- multiple selection enum params -->
196 <!-- how to do defaults for this?? -->
197 <xsl:template match="param[@type='enum_multi']">
198 <xsl:param name="ns">s1.</xsl:param>
199 <xsl:param name="default"/>
200 <select name="{$ns}{@name}" size="2">
201 <xsl:attribute name="multiple"></xsl:attribute>
202 <xsl:for-each select="option">
203 <option value="{@name}"><xsl:if test="contains($default, concat(',', @name, ','))"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
204 </xsl:for-each>
205 </select>
206 </xsl:template>
207
208 <!-- string params -->
209 <xsl:template match="param[@type='string']">
210 <xsl:param name="ns">s1.</xsl:param>
211 <xsl:param name="default"/>
212 <input type="text" name="{$ns}{@name}" size="30" value="{$default}"/>
213 </xsl:template>
214
215 <!-- large string params -->
216 <xsl:template match="param[@type='text']">
217 <xsl:param name="ns">s1.</xsl:param>
218 <xsl:param name="default"/>
219 <textarea name="{$ns}{@name}" cols="50" rows="3"><xsl:value-of select='$default'/></textarea>
220 </xsl:template>
221
222 <!-- multi params - params that are combinations of other params -->
223 <xsl:template match="param[@type='multi']">
224 <xsl:param name="ns">s1.</xsl:param>
225 <xsl:variable name="parent" select="@name"/>
226
227 <table>
228 <tr class="queryfieldheading">
229 <xsl:value-of select="displayItem[@name='name']"/>
230 <xsl:for-each select="param">
231 <td class="queryfieldname"><xsl:value-of select="displayItem[@name='name']"/></td>
232 </xsl:for-each>
233 </tr>
234 <xsl:apply-templates select="." mode="contents">
235 <xsl:with-param name="occurs" select="@occurs"/>
236 <xsl:with-param name="ns" select="$ns"/>
237 </xsl:apply-templates>
238 </table>
239
240 </xsl:template>
241
242 <xsl:template match="param[@type='multi']" mode="contents">
243 <xsl:param name="ns">s1.</xsl:param>
244 <xsl:param name="occurs">1</xsl:param>
245 <xsl:variable name="pos" select="@occurs - $occurs"/>
246 <tr class="queryfieldrow">
247 <xsl:for-each select="param">
248 <xsl:variable name="pname" select="@name"/>
249 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
250 <td class="queryfieldcell">
251 <xsl:choose>
252 <xsl:when test="not(@ignore) or @ignore != $pos">
253 <xsl:apply-templates select="."><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($values, $pos)"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
254 </xsl:when>
255 <xsl:otherwise><!-- put in a hidden placeholder -->
256 <input type="hidden" name='{$ns}{@name}' value=''/>
257 </xsl:otherwise>
258 </xsl:choose>
259 </td>
260 </xsl:for-each>
261 </tr>
262
263 <!-- recursively call this template to get multiple entries -->
264 <xsl:if test="$occurs &gt; 1">
265 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs - 1"/><xsl:with-param name="ns" select="$ns"/></xsl:apply-templates>
266 </xsl:if>
267 </xsl:template>
268
269</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.