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