1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 |
|
---|
3 | <xsl:stylesheet version="1.0"
|
---|
4 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
5 | xmlns:gslib="http://www.greenstone.org/XSL/Library"
|
---|
6 | exclude-result-prefixes="xalan gslib"
|
---|
7 | >
|
---|
8 |
|
---|
9 | <!-- exclude-result-prefixes="xalan gslib" -->
|
---|
10 |
|
---|
11 | <!-- general ............................................................................. -->
|
---|
12 |
|
---|
13 | <xsl:variable name="librarian"></xsl:variable>
|
---|
14 |
|
---|
15 | <xsl:variable name="action" select="/page/pageRequest/@action"/>
|
---|
16 |
|
---|
17 | <xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
|
---|
18 |
|
---|
19 | <xsl:variable name="lang" select="/page/pageRequest/@lang"/>
|
---|
20 |
|
---|
21 | <xsl:variable name="css">
|
---|
22 | <xsl:for-each select="/page/pageResponse/cssFileList/cssFile">
|
---|
23 | <link rel="stylesheet" href="{@path}" type="text/css"/>
|
---|
24 | </xsl:for-each>
|
---|
25 | </xsl:variable>
|
---|
26 |
|
---|
27 | <xsl:variable name="js">
|
---|
28 | <xsl:for-each select="/page/pageResponse/jsFileList/jsFile">
|
---|
29 | <script type="text/javascript" src="{@path}"><xsl:comment>IE needs to have an explicity start and end script tag. This comment is here to ensure the end script tag does not get collapsed into a single open-close in one go element</xsl:comment></script>
|
---|
30 | </xsl:for-each>
|
---|
31 | </xsl:variable>
|
---|
32 |
|
---|
33 | <xsl:template name="metadataItem">
|
---|
34 | <xsl:param name="name"/>
|
---|
35 |
|
---|
36 | <xsl:variable name="x" select="/page/pageResponse/metadataList/metadataItem[@name=$name]" />
|
---|
37 |
|
---|
38 |
|
---|
39 | <xsl:choose>
|
---|
40 | <xsl:when test="$x = ''">
|
---|
41 | metadataItem '<xsl:value-of select="$name"/>' not defined.
|
---|
42 | </xsl:when>
|
---|
43 | <xsl:otherwise>
|
---|
44 | <xsl:for-each select="$x">
|
---|
45 | <xsl:call-template name="expandMetadataAndUiItems" />
|
---|
46 | </xsl:for-each>
|
---|
47 | </xsl:otherwise>
|
---|
48 | </xsl:choose>
|
---|
49 |
|
---|
50 | </xsl:template>
|
---|
51 |
|
---|
52 | <!-- get the uiItem for the given name -->
|
---|
53 | <xsl:template name="uiItem">
|
---|
54 | <xsl:param name="name"/>
|
---|
55 |
|
---|
56 | <xsl:variable name="x" select="/page/pageResponse/uiItemList/uiItem[@name=$name]" />
|
---|
57 |
|
---|
58 | <xsl:choose>
|
---|
59 | <xsl:when test="$x = ''">
|
---|
60 | uiItem '<xsl:value-of select="$name"/>' not defined.
|
---|
61 | </xsl:when>
|
---|
62 | <xsl:otherwise>
|
---|
63 | <xsl:for-each select="$x">
|
---|
64 | <xsl:call-template name="expandMetadataAndUiItems" />
|
---|
65 | </xsl:for-each>
|
---|
66 | </xsl:otherwise>
|
---|
67 | </xsl:choose>
|
---|
68 |
|
---|
69 | </xsl:template>
|
---|
70 |
|
---|
71 | <!-- site level stuff ....................................................................... -->
|
---|
72 |
|
---|
73 | <xsl:variable name="collections" select="/page/pageResponse/collectionList/collection"/>
|
---|
74 |
|
---|
75 | <xsl:template name="collection_title">
|
---|
76 | <xsl:value-of disable-output-escaping='yes' select="./displayItem[@name='name']"/>
|
---|
77 | </xsl:template>
|
---|
78 |
|
---|
79 | <xsl:template name="collection_description">
|
---|
80 | <xsl:value-of disable-output-escaping='yes' select="./displayItem[@name='description']"/>
|
---|
81 | </xsl:template>
|
---|
82 |
|
---|
83 | <xsl:template name="collection_url">
|
---|
84 | <xsl:value-of select="$librarian" />?a=p&sa=about&c=<xsl:value-of select="@name" />
|
---|
85 | </xsl:template>
|
---|
86 |
|
---|
87 | <xsl:variable name="site_homeUrl">
|
---|
88 | <xsl:value-of select="$librarian" />?a=p&sa=home
|
---|
89 | </xsl:variable>
|
---|
90 |
|
---|
91 | <!-- collection level stuff ....................................................................... -->
|
---|
92 |
|
---|
93 | <xsl:variable name="collection" select="/page/pageResponse/collection/@name"/>
|
---|
94 |
|
---|
95 | <xsl:variable name="collection_homeUrl">
|
---|
96 | <xsl:value-of select="$librarian" />?a=p&sa=about&c=<xsl:value-of select="$collection"/>
|
---|
97 | </xsl:variable>
|
---|
98 |
|
---|
99 | <xsl:variable name="services" select="/page/pageResponse/collection/serviceList/service[@type='query' or @type='browse']"/>
|
---|
100 |
|
---|
101 | <xsl:template name="service_title">
|
---|
102 | <xsl:param name="serviceName"/>
|
---|
103 | <xsl:value-of select="./displayItem[@name='name']"/>
|
---|
104 | </xsl:template>
|
---|
105 |
|
---|
106 | <xsl:template name="service_description">
|
---|
107 | <xsl:param name="serviceName"/>
|
---|
108 | <xsl:value-of select="./displayItem[@name='description']"/>
|
---|
109 | </xsl:template>
|
---|
110 |
|
---|
111 | <xsl:template name="service_url">
|
---|
112 | <xsl:variable name="serviceAction">
|
---|
113 | <xsl:choose>
|
---|
114 | <!-- this hard coding doesnt seem like a good idea: why isnt the appropriate action given as an attribute of the service? -->
|
---|
115 | <xsl:when test="@type='query'">q</xsl:when>
|
---|
116 | <xsl:when test="@type='browse'">b</xsl:when>
|
---|
117 | <xsl:when test="@type='process'">pr</xsl:when>
|
---|
118 | <xsl:when test="@type='applet'">a</xsl:when>
|
---|
119 | <xsl:otherwise>DO_NOT_DISPLAY</xsl:otherwise>
|
---|
120 | </xsl:choose>
|
---|
121 | </xsl:variable>
|
---|
122 |
|
---|
123 | <xsl:value-of select="$librarian"/>?a=<xsl:value-of select="$serviceAction"/>&rt=d&s=<xsl:value-of select="@name"/>&c=<xsl:value-of select="$collection"/>
|
---|
124 | </xsl:template>
|
---|
125 |
|
---|
126 | <xsl:variable name="classifiers" select="/page/pageResponse/collection/serviceList//classifier"/>
|
---|
127 |
|
---|
128 | <xsl:template name="classifier_title">
|
---|
129 | <xsl:value-of select="./displayItem[@name='name']"/>
|
---|
130 | </xsl:template>
|
---|
131 |
|
---|
132 | <xsl:template name="classifier_description">
|
---|
133 | <xsl:value-of select="./displayItem[@name='description']"/>
|
---|
134 | </xsl:template>
|
---|
135 |
|
---|
136 | <xsl:template name="classifier_url">
|
---|
137 | <xsl:value-of select="$librarian"/>?a=b&rt=r&s=<xsl:value-of select="../../@name"/>&c=<xsl:value-of select="$collection"/>&cl=<xsl:value-of select="@name"/>
|
---|
138 | </xsl:template>
|
---|
139 |
|
---|
140 | <!-- searching ............................................................................. -->
|
---|
141 |
|
---|
142 | <xsl:variable name="search_hiddenInputs">
|
---|
143 | <input name="a" type="hidden" value="q" />
|
---|
144 | <input name="sa" type="hidden" value="" />
|
---|
145 | <input name="rt" type="hidden" value="rd" />
|
---|
146 | <input name="s" type="hidden" value="TextQuery" />
|
---|
147 | <input name="c" type="hidden" value="{$collection}" />
|
---|
148 | <input name="startPage" type="hidden" value="1" />
|
---|
149 | </xsl:variable>
|
---|
150 |
|
---|
151 | <xsl:variable name="search_docsReturned" select="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']" />
|
---|
152 |
|
---|
153 | <xsl:variable name="search_startIndex" select="'1'"/>
|
---|
154 |
|
---|
155 | <xsl:variable name="search_endIndex" select="'20'"/>
|
---|
156 |
|
---|
157 |
|
---|
158 |
|
---|
159 | <xsl:variable name="search_query" select="/page/pageResponse/metadataList/metadata[@name='query']" />
|
---|
160 |
|
---|
161 | <xsl:variable name="search_queryTerms" select="/page/pageResponse/termList/term"/>
|
---|
162 |
|
---|
163 | <xsl:template name="search_queryTerm_text">
|
---|
164 | <xsl:value-of select="./@name"/>
|
---|
165 | </xsl:template>
|
---|
166 |
|
---|
167 | <xsl:template name="search_queryTerm_freq">
|
---|
168 | <xsl:value-of select="./@freq"/>
|
---|
169 | </xsl:template>
|
---|
170 |
|
---|
171 |
|
---|
172 | <xsl:variable name="search_results" select="/page/pageResponse/documentNodeList/documentNode"/>
|
---|
173 |
|
---|
174 | <xsl:template name="metadata">
|
---|
175 | <xsl:param name="name"/>
|
---|
176 |
|
---|
177 | <xsl:value-of disable-output-escaping="yes" select="./metadataList/metadata[@name=$name]" />
|
---|
178 | </xsl:template>
|
---|
179 |
|
---|
180 | <xsl:template name="search_param_li">
|
---|
181 | <xsl:param name="search_param"/>
|
---|
182 | <li>
|
---|
183 | <xsl:for-each select="$search_param/displayItem[@name='name']">
|
---|
184 | <xsl:value-of select="." />
|
---|
185 | </xsl:for-each>
|
---|
186 |
|
---|
187 | <xsl:choose>
|
---|
188 |
|
---|
189 | <xsl:when test="$search_param/@type='boolean' or $search_param/@type='enum_single'">
|
---|
190 | <select name="s1.{$search_param/@name}">
|
---|
191 | <xsl:for-each select="$search_param/option">
|
---|
192 | <option name="{@name}">
|
---|
193 | <xsl:for-each select="./displayItem[@name='name']">
|
---|
194 | <xsl:value-of select="." />
|
---|
195 | </xsl:for-each>
|
---|
196 | </option>
|
---|
197 | </xsl:for-each>
|
---|
198 | </select>
|
---|
199 | </xsl:when>
|
---|
200 |
|
---|
201 |
|
---|
202 | <xsl:when test="$search_param/@type='integer'">
|
---|
203 | <input name="s1.{$search_param/@name}" value="{$search_param/@default}"/>
|
---|
204 | </xsl:when>
|
---|
205 |
|
---|
206 | <xsl:when test="$search_param/@type='invisible'">
|
---|
207 | <input name="s1.{$search_param/@name}" value="{$search_param/@default}" type="hidden"/>
|
---|
208 | </xsl:when>
|
---|
209 |
|
---|
210 | </xsl:choose>
|
---|
211 | </li>
|
---|
212 |
|
---|
213 | </xsl:template>
|
---|
214 |
|
---|
215 |
|
---|
216 |
|
---|
217 |
|
---|
218 |
|
---|
219 |
|
---|
220 |
|
---|
221 |
|
---|
222 |
|
---|
223 |
|
---|
224 |
|
---|
225 |
|
---|
226 |
|
---|
227 |
|
---|
228 |
|
---|
229 |
|
---|
230 |
|
---|
231 | <!-- browsing ............................................................................. -->
|
---|
232 |
|
---|
233 | <xsl:variable name="currentClassifier" select="/page/pageResponse/collection/serviceList//classifier[@name = /page/pageResponse/classifier/@name]" />
|
---|
234 |
|
---|
235 | <xsl:variable name="topLevelClassifierNodes" select="/page/pageResponse/classifier/classifierNode"/>
|
---|
236 |
|
---|
237 | <xsl:variable name="topLevelClassifierNodeIds" select="/page/pageResponse/classifier/classifierNode/@nodeID"/>
|
---|
238 |
|
---|
239 | <xsl:template name="classifierNode_title">
|
---|
240 | <xsl:value-of select="./metadataList/metadata[@name='Title']"/>
|
---|
241 | </xsl:template>
|
---|
242 |
|
---|
243 | <xsl:template name="classifierNode_url">
|
---|
244 | <xsl:value-of select="$librarian"/>
|
---|
245 | ?a=b&rt=r&s=
|
---|
246 | <xsl:value-of select="/page/pageResponse/service/@name"/>
|
---|
247 | &c=
|
---|
248 | <xsl:value-of select="$collection"/>
|
---|
249 | &cl=
|
---|
250 | <xsl:value-of select="@nodeID" />
|
---|
251 | </xsl:template>
|
---|
252 |
|
---|
253 | <xsl:template name="documentNode_title">
|
---|
254 | <xsl:value-of select="./metadataList/metadata[@name='Title']"/>
|
---|
255 | </xsl:template>
|
---|
256 |
|
---|
257 | <xsl:template name="documentNode_url">
|
---|
258 | <xsl:value-of select="$librarian"/>?a=d&
|
---|
259 | c=<xsl:value-of select="$collection"/>&
|
---|
260 | d=<xsl:value-of select="@nodeID"/>&sib=1
|
---|
261 | &p.a=b&p.s=ClassifierBrowse
|
---|
262 | </xsl:template>
|
---|
263 |
|
---|
264 |
|
---|
265 |
|
---|
266 |
|
---|
267 |
|
---|
268 | <!-- document viewing..................................................................... -->
|
---|
269 |
|
---|
270 | <xsl:variable name="document_coverImage_exists" select="/page/pageResponse/document/@hasCoverImage" />
|
---|
271 |
|
---|
272 | <xsl:variable name="document_coverImage_url">
|
---|
273 | <xsl:if test="$document_coverImage_exists">
|
---|
274 | <xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<xsl:value-of select="normalize-space(/page/pageResponse/document/metadataList/metadata[@name='archivedir'])"/>/cover.jpg
|
---|
275 | </xsl:if>
|
---|
276 | </xsl:variable>
|
---|
277 |
|
---|
278 | <xsl:variable name="document_type">
|
---|
279 | <xsl:choose>
|
---|
280 | <xsl:when test="count(/page/pageResponse/document//documentNode) = 1">simple</xsl:when>
|
---|
281 | <xsl:otherwise>
|
---|
282 | <xsl:value-of select="/page/pageResponse/document/@docType"/>
|
---|
283 | </xsl:otherwise>
|
---|
284 | </xsl:choose>
|
---|
285 | </xsl:variable>
|
---|
286 |
|
---|
287 |
|
---|
288 | <xsl:variable name="document_hash" select="/page/pageResponse/document/documentNode/@nodeID" />
|
---|
289 |
|
---|
290 | <xsl:variable name="document_is_expanded" select="/page/pageRequest/paramList/param[@name='ed']/@value=1"/>
|
---|
291 |
|
---|
292 | <xsl:variable name="document_expanded_url">
|
---|
293 | <xsl:value-of select="$librarian"/>?a=d&
|
---|
294 | c=<xsl:value-of select="$collection"/>&
|
---|
295 | d=<xsl:value-of select="$document_hash"/>&
|
---|
296 | ed=1
|
---|
297 | </xsl:variable>
|
---|
298 |
|
---|
299 | <xsl:variable name="document_collapsed_url">
|
---|
300 | <xsl:value-of select="$librarian"/>?a=d&
|
---|
301 | c=<xsl:value-of select="$collection"/>&
|
---|
302 | d=<xsl:value-of select="$document_hash"/>
|
---|
303 | </xsl:variable>
|
---|
304 |
|
---|
305 | <xsl:variable name="document_title" >
|
---|
306 | <xsl:choose>
|
---|
307 | <xsl:when test="$document_type='simple'">
|
---|
308 | <xsl:value-of disable-output-escaping='yes' select="/page/pageResponse/document/metadataList/metadata[@name='Title']" />
|
---|
309 | </xsl:when>
|
---|
310 | <xsl:otherwise>
|
---|
311 | <xsl:value-of disable-output-escaping='yes' select="/page/pageResponse/document/documentNode/metadataList/metadata[@name='Title']"/>
|
---|
312 | </xsl:otherwise>
|
---|
313 | </xsl:choose>
|
---|
314 | </xsl:variable>
|
---|
315 |
|
---|
316 | <xsl:variable name="document_content" >
|
---|
317 | <xsl:value-of disable-output-escaping='yes' select="/page/pageResponse/document/documentNode/nodeContent" />
|
---|
318 | </xsl:variable>
|
---|
319 |
|
---|
320 | <xsl:variable name="document_allSections" select="/page/pageResponse/document//documentNode[@nodeType!='root']" />
|
---|
321 |
|
---|
322 | <xsl:variable name="document_topLevelNodes" select="/page/pageResponse/document/documentNode/documentNode" />
|
---|
323 |
|
---|
324 |
|
---|
325 | <xsl:variable name="document_topLevelSections" select="/page/pageResponse/document/documentNode/documentNode" />
|
---|
326 |
|
---|
327 | <xsl:template name="document_section_id">
|
---|
328 | <xsl:value-of select="./@nodeID"/>
|
---|
329 | </xsl:template>
|
---|
330 |
|
---|
331 | <xsl:template name="document_section_title">
|
---|
332 | <xsl:value-of disable-output-escaping='yes' select="./metadataList/metadata[@name='Title']"/>
|
---|
333 | </xsl:template>
|
---|
334 |
|
---|
335 | <xsl:template name="document_section_depth">
|
---|
336 | <xsl:value-of select="count(./ancestor::documentNode)"/>
|
---|
337 | </xsl:template>
|
---|
338 |
|
---|
339 | <xsl:template name="document_section_content">
|
---|
340 | <xsl:value-of disable-output-escaping='yes' select="./nodeContent"/>
|
---|
341 | </xsl:template>
|
---|
342 |
|
---|
343 |
|
---|
344 | <xsl:variable name="document_currentSection" select="/page/pageResponse/document//nodeContent/.." />
|
---|
345 |
|
---|
346 | <xsl:variable name="document_currentSection_title" select="$document_currentSection/metadataList/metadata[@name='Title']" />
|
---|
347 |
|
---|
348 | <xsl:variable name="document_currentSection_content">
|
---|
349 | <xsl:value-of disable-output-escaping='yes' select="$document_currentSection/nodeContent" />
|
---|
350 | </xsl:variable>
|
---|
351 |
|
---|
352 | <xsl:variable name="document_previousSection" select="$document_currentSection/preceding::documentNode[@nodeType='leaf'][1]"/>
|
---|
353 |
|
---|
354 | <xsl:variable name="document_previousSection_title" select="$document_previousSection/metadataList/metadata[@name='Title']"/>
|
---|
355 |
|
---|
356 | <xsl:variable name="document_previousSection_url">
|
---|
357 | <xsl:value-of select="$librarian"/>?a=d&
|
---|
358 | c=<xsl:value-of select="$collection"/>&
|
---|
359 | d=<xsl:value-of select="$document_previousSection/@nodeID"/>&
|
---|
360 | sib=1&ec=1
|
---|
361 | </xsl:variable>
|
---|
362 |
|
---|
363 | <xsl:variable name="document_nextSection" select="$document_currentSection/following::documentNode[@nodeType='leaf'][1]"/>
|
---|
364 |
|
---|
365 | <xsl:variable name="document_nextSection_title" select="$document_nextSection/metadataList/metadata[@name='Title']"/>
|
---|
366 |
|
---|
367 | <xsl:variable name="document_nextSection_url">
|
---|
368 | <xsl:value-of select="$librarian"/>?a=d&
|
---|
369 | c=<xsl:value-of select="$collection"/>&
|
---|
370 | d=<xsl:value-of select="$document_nextSection/@nodeID"/>&
|
---|
371 | sib=1&ec=1
|
---|
372 | </xsl:variable>
|
---|
373 |
|
---|
374 | <xsl:variable name="document_ancestorSections" select="$document_currentSection/ancestor::documentNode[@nodeType='internal']"/>
|
---|
375 |
|
---|
376 | <xsl:variable name="document_ancestorSections_titles" select="$document_ancestorSections/metadataList/metadata[@name='Title']"/>
|
---|
377 |
|
---|
378 |
|
---|
379 |
|
---|
380 |
|
---|
381 |
|
---|
382 |
|
---|
383 |
|
---|
384 |
|
---|
385 | <!-- stuff that no-one should need to know about........................................ -->
|
---|
386 |
|
---|
387 | <!-- produce an exact copy of the current node, but expand and replace all metadataItems and uiItems found within. -->
|
---|
388 | <xsl:template name="expandMetadataAndUiItems">
|
---|
389 | <xsl:for-each select="*|text()">
|
---|
390 | <xsl:choose>
|
---|
391 |
|
---|
392 | <!-- if node is a metadataItem, expand it -->
|
---|
393 | <xsl:when test="self::node()[self::metadataItem]">
|
---|
394 | <xsl:call-template name="metadataItem">
|
---|
395 | <xsl:with-param name="name"><xsl:value-of select="@name" disable-output-escaping="yes"/></xsl:with-param>
|
---|
396 | </xsl:call-template>
|
---|
397 | </xsl:when>
|
---|
398 |
|
---|
399 | <!-- if node is a uiItem, expand it -->
|
---|
400 | <xsl:when test="self::node()[self::uiItem]">
|
---|
401 | <xsl:call-template name="uiItem">
|
---|
402 | <xsl:with-param name="name"><xsl:value-of select="@name" disable-output-escaping="yes"/></xsl:with-param>
|
---|
403 | </xsl:call-template>
|
---|
404 | </xsl:when>
|
---|
405 |
|
---|
406 | <xsl:when test="self::text()">
|
---|
407 | <xsl:value-of select="." disable-output-escaping="yes"/>
|
---|
408 | </xsl:when>
|
---|
409 |
|
---|
410 | <!-- if a regular node -->
|
---|
411 | <xsl:otherwise>
|
---|
412 | <xsl:variable name="element-name" select="name()"/>
|
---|
413 | <xsl:element name="{$element-name}">
|
---|
414 | <xsl:for-each select="@*">
|
---|
415 | <xsl:variable name="attribute-name" select="name()"/>
|
---|
416 | <xsl:attribute name="{$attribute-name}">
|
---|
417 | <xsl:call-template name="attribute-filter"/>
|
---|
418 | </xsl:attribute>
|
---|
419 | </xsl:for-each>
|
---|
420 | <xsl:call-template name="expandMetadataAndUiItems" />
|
---|
421 | </xsl:element>
|
---|
422 | </xsl:otherwise>
|
---|
423 | </xsl:choose>
|
---|
424 | </xsl:for-each>
|
---|
425 |
|
---|
426 | </xsl:template>
|
---|
427 |
|
---|
428 | <xsl:template name="attribute-filter"><xsl:value-of select="."/></xsl:template>
|
---|
429 |
|
---|
430 | </xsl:stylesheet>
|
---|
431 |
|
---|
432 |
|
---|