source: greenstone3/trunk/web/ui/xslt/library.xsl@ 16502

Last change on this file since 16502 was 16502, checked in by max, 16 years ago

Fixed space problem in URLs during browsing & opening documents.

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