source: trunk/gsdl3/web/interfaces/nzdl/transform/query.xsl@ 5387

Last change on this file since 5387 was 5387, checked in by kjdon, 21 years ago

navigation bar no longer part of page banner, removed /gsdl3 from form action

  • Property svn:keywords set to Author Date Id Revision
File size: 10.1 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 extension-element-prefixes="java util"
7 exclude-result-prefixes="java util">
8
9
10 <xsl:include href="style.xsl"/>
11 <xsl:include href="service-params.xsl"/>
12 <xsl:include href="querytools.xsl"/>
13
14 <xsl:output method="html"/>
15
16 <xsl:template name="pageHead">
17 <head>
18 <title><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'nzdl')"/></title>
19 </head>
20 <xsl:call-template name="headScript"/>
21 </xsl:template>
22
23 <xsl:template match="pageResponse">
24 <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
25
26 <center>
27 <xsl:call-template name="standardPageBanner">
28 <xsl:with-param name="collName" select="$collName"/>
29 <xsl:with-param name="pageType">search</xsl:with-param>
30 </xsl:call-template>
31 <xsl:call-template name="navigationBar">
32 <xsl:with-param name="collName" select="$collName"/>
33 </xsl:call-template>
34 <xsl:apply-templates select="service">
35 <xsl:with-param name="collName" select="$collName"/>
36 </xsl:apply-templates>
37 </center>
38
39 <xsl:if test="documentNodeList">
40 <xsl:call-template name="query-response">
41 <xsl:with-param name="collName" select="$collName"/>
42 </xsl:call-template>
43 </xsl:if>
44 <center>
45 <xsl:call-template name="dividerBar"/>
46 </center>
47 </xsl:template>
48
49 <xsl:template name="query-response">
50 <xsl:param name="collName"/>
51 <xsl:call-template name="dividerBar">
52 <xsl:with-param name='text'><xsl:value-of select="util:getInterfaceText('nzdl', /page/@lang, 'query.results')"/></xsl:with-param></xsl:call-template>
53
54 <!-- If query term information is available, display it -->
55 <br/>
56 <xsl:call-template name="termInfo"/>
57 <!-- If the number of matching documents is known, display it -->
58 <xsl:call-template name="matchDocs"/>
59
60 <!-- Display the matching documents -->
61 <xsl:call-template name="resultList">
62 <xsl:with-param name="collName" select="$collName"/>
63 </xsl:call-template>
64 <!-- next and prev links at bottom of page -->
65 <xsl:call-template name="resultNavigation"/>
66 </xsl:template>
67
68
69 <xsl:template match="service">
70 <xsl:param name="collName"/>
71 <xsl:variable name="subaction" select="../pageRequest/@subaction"/>
72 <form name="QueryForm" method="get" action="{$library_name}">
73 <input type="hidden" name="a" value="q"/>
74 <input type="hidden" name="sa" value="{$subaction}"/>
75 <input type="hidden" name="rt" value="r"/>
76 <input type="hidden" name="s" value="{@name}"/>
77 <input type="hidden" name="c" value="{$collName}"/>
78 <input type="hidden" name="hn" value="1"/>
79 <xsl:apply-templates select="paramList"/>
80 </form>
81 </xsl:template>
82
83 <!-- a special handling of the param list - we override the one in service-params -->
84 <xsl:template match="paramList" priority='2'>
85 <table>
86 <tr><td>
87 Search for <xsl:apply-templates select="param[@name='index']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='index']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates><xsl:if test="param[@name='level']">at <xsl:apply-templates select="param[@name='level']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='level']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> level</xsl:if><xsl:call-template name='query_mode'/>
88 </td></tr>
89 <xsl:call-template name="query-and-submit"/>
90 </table>
91 </xsl:template>
92
93 <!-- new template for match mode -->
94 <xsl:template name='query_mode'>
95 <xsl:variable name="qt" select="/page/pageRequest/paramList/param[@name='qt']/@value"/>
96 <xsl:choose>
97 <xsl:when test="$qt=1">
98 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>
99 <xsl:choose>
100 <xsl:when test="$qfm=1">
101 and display results in <xsl:apply-templates select="param[@name='sortBy']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='sortBy']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> order
102 </xsl:when>
103 <xsl:otherwise>
104 which contain <xsl:apply-templates select="param[@name='matchMode']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='matchMode']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> of
105 </xsl:otherwise>
106 </xsl:choose>
107 </xsl:when>
108 <xsl:otherwise>
109 <xsl:variable name="ct" select="/page/pageRequest/paramList/param[@name='ct']/@value"/>
110 <xsl:variable name="qm" select="/page/pageRequest/paramList/param[@name='qm']/@value"/>
111 <xsl:choose>
112 <xsl:when test="$qm=1 and $ct=0">
113 using ranked/bool query
114 </xsl:when>
115 <xsl:when test="$qm=1 and $ct=1">
116 and display results in <xsl:apply-templates select="param[@name='sortBy']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='sortBy']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> order
117 </xsl:when>
118 <xsl:otherwise>
119 which contain <xsl:apply-templates select="param[@name='matchMode']"><xsl:with-param name="default"><xsl:apply-templates select="param[@name='matchMode']" mode="calculate-default"/></xsl:with-param></xsl:apply-templates> of the words
120 </xsl:otherwise>
121 </xsl:choose>
122 </xsl:otherwise>
123 </xsl:choose>
124 </xsl:template>
125
126 <xsl:template match="param[@name='matchMode']" mode='query1'>
127 <xsl:param name='default'/>
128 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>
129 <xsl:choose>
130 <xsl:when test="$qfm=1">
131 and display results in <xsl:apply-templates select="../param[@name='sortBy']"><xsl:with-param name="default" select="$default"/></xsl:apply-templates> order
132 </xsl:when>
133 <xsl:otherwise>
134 which contain <xsl:apply-templates select='.'><xsl:with-param name="default" select="$default"/></xsl:apply-templates> of the words
135 </xsl:otherwise>
136 </xsl:choose>
137 </xsl:template>
138
139 <xsl:template name="query-and-submit">
140 <xsl:variable name="qt" select="/page/pageRequest/paramList/param[@name='qt']/@value"/>
141 <xsl:choose>
142 <xsl:when test="$qt=1"> <!-- doing form query -->
143 <xsl:variable name="qfm" select="/page/pageRequest/paramList/param[@name='qfm']/@value"/>
144 <xsl:choose>
145 <xsl:when test="$qfm=1">
146 <tr><td><xsl:apply-templates select="param[@name='complexField']"/></td></tr>
147 </xsl:when>
148 <xsl:otherwise>
149 <tr><td><xsl:apply-templates select="param[@name='simpleField']"/></td></tr>
150 </xsl:otherwise>
151 </xsl:choose>
152 <tr><td align='right'>
153 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="../displayItem[@name='submit']"/></xsl:attribute></input>
154 </td></tr>
155 </xsl:when>
156 <xsl:otherwise> <!-- doing text query -->
157 <xsl:variable name="qb" select="/page/pageRequest/paramList/param[@name='qb']/@value"/>
158 <xsl:choose>
159 <xsl:when test="$qb=1"><!-- large query box -->
160 <tr><td>
161 <textarea name="query" cols='63' rows='10'>
162 <xsl:apply-templates select="param[@name='query']" mode="calculate-default"/><xsl:text> </xsl:text><!-- put a space here just in case there is no value- mozilla craps out if have a <textarea /> element -->
163 </textarea>
164 </td></tr>
165 <tr><td align='right'>
166 <input type="submit"><xsl:attribute name="value"><xsl:value-of select="../displayItem[@name='submit']"/></xsl:attribute></input>
167 </td></tr>
168 </xsl:when>
169 <xsl:otherwise>
170 <tr><td>
171 <xsl:variable name="qs"><xsl:apply-templates select="param[@name='query']" mode="calculate-default"/></xsl:variable>
172 <nobr><xsl:apply-templates select="param[@name='query']"><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs)"/></xsl:apply-templates><input type="submit"><xsl:attribute name="value"><xsl:value-of select="../displayItem[@name='submit']"/></xsl:attribute></input></nobr>
173 </td></tr>
174 </xsl:otherwise>
175 </xsl:choose>
176 </xsl:otherwise>
177 </xsl:choose>
178 </xsl:template>
179
180 <!-- overwrite the multi param to use our value of occurs, not the one with the param -->
181 <xsl:template match="param[@type='multi']" priority='2'>
182 <xsl:variable name="parent" select="@name"/>
183 <table>
184 <tr>
185 <xsl:for-each select="param">
186 <xsl:variable name='pname' select='@name'/>
187 <td><xsl:value-of select="displayItem[@name='name']"/></td>
188 </xsl:for-each>
189 </tr>
190 <!-- the number of times to display this is the qfn variable -->
191 <xsl:variable name="numbox"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='qfn']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='qfn']/@value"/></xsl:when><xsl:otherwise>4</xsl:otherwise></xsl:choose></xsl:variable>
192 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$numbox"/><xsl:with-param name="pos" select="0"/></xsl:apply-templates>
193 </table>
194 </xsl:template>
195
196 <xsl:template match="param[@type='multi']" mode="contents">
197 <xsl:param name="occurs"/>
198 <xsl:param name="pos"/>
199 <!-- <xsl:variable name="pos" select="@occurs - $occurs"/>-->
200 <tr><xsl:for-each select="param">
201 <xsl:variable name="pname" select="@name"/>
202 <xsl:variable name="values" select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
203 <td><xsl:choose>
204 <xsl:when test="not(@ignore) or @ignore != $pos">
205 <xsl:apply-templates select='.'><xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.getNumberedItem($values, $pos)"/></xsl:apply-templates>
206 </xsl:when>
207 <xsl:otherwise><!-- put in a hidden placeholder -->
208 <input type="hidden" name='{@name}' value=''/>
209 </xsl:otherwise>
210 </xsl:choose></td>
211 </xsl:for-each></tr>
212 <!-- recursively call this template to get multiple entries -->
213 <xsl:if test="$pos &lt; ($occurs - 1)">
214 <xsl:apply-templates select="." mode="contents"><xsl:with-param name="occurs" select="$occurs"/><xsl:with-param name="pos" select="$pos+1"/></xsl:apply-templates>
215 </xsl:if>
216 </xsl:template>
217</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.