source: deprecated/ui/xslt/library.xsl

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

Solve the url issues after extracted gslib statements.

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;
84c=<xsl:value-of select="@name" />
85</xsl:template>
86
87<xsl:variable name="site_homeUrl">
88<xsl:value-of select="$librarian" />?a=p&amp;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&amp;sa=about&amp;
97c=<xsl:value-of select="$collection"/>
98</xsl:variable>
99
100<xsl:variable name="services" select="/page/pageResponse/collection/serviceList/service[@type='query' or @type='browse']"/>
101
102<xsl:template name="service_title">
103 <xsl:param name="serviceName"/>
104 <xsl:value-of select="./displayItem[@name='name']"/>
105</xsl:template>
106
107<xsl:template name="service_description">
108 <xsl:param name="serviceName"/>
109 <xsl:value-of select="./displayItem[@name='description']"/>
110</xsl:template>
111
112<xsl:template name="service_url">
113 <xsl:variable name="serviceAction">
114 <xsl:choose>
115 <!-- this hard coding doesnt seem like a good idea: why isnt the appropriate action given as an attribute of the service? -->
116 <xsl:when test="@type='query'">q</xsl:when>
117 <xsl:when test="@type='browse'">b</xsl:when>
118 <xsl:when test="@type='process'">pr</xsl:when>
119 <xsl:when test="@type='applet'">a</xsl:when>
120 <xsl:otherwise>DO_NOT_DISPLAY</xsl:otherwise>
121 </xsl:choose>
122 </xsl:variable>
123
124<xsl:value-of select="$librarian"/>?
125a=<xsl:value-of select="$serviceAction"/>&amp;rt=d&amp;
126s=<xsl:value-of select="@name"/>&amp;
127c=<xsl:value-of select="$collection"/>
128</xsl:template>
129
130<xsl:variable name="classifiers" select="/page/pageResponse/collection/serviceList//classifier"/>
131
132<xsl:template name="classifier_title">
133 <xsl:value-of select="./displayItem[@name='name']"/>
134</xsl:template>
135
136<xsl:template name="classifier_description">
137 <xsl:value-of select="./displayItem[@name='description']"/>
138</xsl:template>
139
140<xsl:template name="classifier_url">
141<xsl:value-of select="$librarian"/>?a=b&amp;rt=r&amp;
142s=<xsl:value-of select="../../@name"/>&amp;
143c=<xsl:value-of select="$collection"/>&amp;
144cl=<xsl:value-of select="@name"/>
145</xsl:template>
146
147<!-- searching ............................................................................. -->
148
149<xsl:variable name="search_hiddenInputs">
150 <input name="a" type="hidden" value="q" />
151 <input name="sa" type="hidden" value="" />
152 <input name="rt" type="hidden" value="rd" />
153 <input name="s" type="hidden" value="TextQuery" />
154 <input name="c" type="hidden" value="{$collection}" />
155 <input name="startPage" type="hidden" value="1" />
156</xsl:variable>
157
158<xsl:variable name="search_docsReturned" select="/page/pageResponse/metadataList/metadata[@name='numDocsReturned']" />
159
160<xsl:variable name="search_startIndex" select="'1'"/>
161
162<xsl:variable name="search_endIndex" select="'20'"/>
163
164
165
166<xsl:variable name="search_query" select="/page/pageResponse/metadataList/metadata[@name='query']" />
167
168<xsl:variable name="search_queryTerms" select="/page/pageResponse/termList/term"/>
169
170<xsl:template name="search_queryTerm_text">
171 <xsl:value-of select="./@name"/>
172</xsl:template>
173
174<xsl:template name="search_queryTerm_freq">
175 <xsl:value-of select="./@freq"/>
176</xsl:template>
177
178
179<xsl:variable name="search_results" select="/page/pageResponse/documentNodeList/documentNode"/>
180
181<xsl:template name="metadata">
182 <xsl:param name="name"/>
183
184 <xsl:value-of disable-output-escaping="yes" select="./metadataList/metadata[@name=$name]" />
185</xsl:template>
186
187<xsl:template name="search_param_li">
188 <xsl:param name="search_param"/>
189 <li>
190 <xsl:for-each select="$search_param/displayItem[@name='name']">
191 <xsl:value-of select="." />
192 </xsl:for-each>
193
194 <xsl:choose>
195
196 <xsl:when test="$search_param/@type='boolean' or $search_param/@type='enum_single'">
197 <select name="s1.{$search_param/@name}">
198 <xsl:for-each select="$search_param/option">
199 <option name="{@name}">
200 <xsl:for-each select="./displayItem[@name='name']">
201 <xsl:value-of select="." />
202 </xsl:for-each>
203 </option>
204 </xsl:for-each>
205 </select>
206 </xsl:when>
207
208
209 <xsl:when test="$search_param/@type='integer'">
210 <input name="s1.{$search_param/@name}" value="{$search_param/@default}"/>
211 </xsl:when>
212
213 <xsl:when test="$search_param/@type='invisible'">
214 <input name="s1.{$search_param/@name}" value="{$search_param/@default}" type="hidden"/>
215 </xsl:when>
216
217 </xsl:choose>
218 </li>
219
220</xsl:template>
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
244<xsl:template name="classifierNode_url">
245
246<xsl:value-of select="$librarian"/>
247?a=b&amp;rt=r&amp;
248s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;
249c=<xsl:value-of select="$collection"/>&amp;
250cl=<xsl:value-of select="@nodeID" /><xsl:if test="classifierNode|documentNode">.pr</xsl:if>
251
252</xsl:template>
253
254
255<xsl:template name="documentNode_title">
256
257<xsl:value-of select="./metadataList/metadata[@name='Title']"/>
258
259</xsl:template>
260
261
262<xsl:template name="documentNode_url">
263
264
265
266<xsl:value-of select="$librarian"/>?a=d&amp;
267c=<xsl:value-of select="$collection"/>&amp;
268d=<xsl:value-of select="@nodeID"/>&amp;
269<!-- dt=<xsl:value-of select="@docType"/>&amp; -->
270sib=1&amp;
271p.a=b&amp;
272p.s=ClassifierBrowse
273
274</xsl:template>
275
276
277
278
279
280
281
282<!-- document viewing..................................................................... -->
283
284<xsl:variable name="document_coverImage_exists" select="/page/pageResponse/document/@hasCoverImage" />
285
286<xsl:variable name="document_coverImage_url">
287 <xsl:if test="$document_coverImage_exists">
288 <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
289 </xsl:if>
290</xsl:variable>
291
292<xsl:variable name="document_type">
293 <xsl:choose>
294 <xsl:when test="count(/page/pageResponse/document//documentNode) = 1">simple</xsl:when>
295 <xsl:otherwise>
296 <xsl:value-of select="/page/pageResponse/document/@docType"/>
297 </xsl:otherwise>
298 </xsl:choose>
299</xsl:variable>
300
301
302<xsl:variable name="document_hash" select="/page/pageResponse/document/documentNode/@nodeID" />
303
304<xsl:variable name="document_is_expanded" select="/page/pageRequest/paramList/param[@name='ed']/@value=1"/>
305
306<xsl:variable name="document_expanded_url">
307<xsl:value-of select="$librarian"/>?a=d&amp;
308c=<xsl:value-of select="$collection"/>&amp;
309d=<xsl:value-of select="$document_hash"/>&amp;
310ed=1
311</xsl:variable>
312
313<xsl:variable name="document_collapsed_url">
314<xsl:value-of select="$librarian"/>?a=d&amp;
315c=<xsl:value-of select="$collection"/>&amp;
316d=<xsl:value-of select="$document_hash"/>
317</xsl:variable>
318
319<xsl:variable name="document_title" >
320 <xsl:choose>
321 <xsl:when test="$document_type='simple'">
322 <xsl:value-of disable-output-escaping='yes' select="/page/pageResponse/document/metadataList/metadata[@name='Title']" />
323 </xsl:when>
324 <xsl:otherwise>
325 <xsl:value-of disable-output-escaping='yes' select="/page/pageResponse/document/documentNode/metadataList/metadata[@name='Title']"/>
326 </xsl:otherwise>
327 </xsl:choose>
328</xsl:variable>
329
330<xsl:variable name="document_content" >
331 <xsl:value-of disable-output-escaping='yes' select="/page/pageResponse/document/documentNode/nodeContent" />
332</xsl:variable>
333
334<xsl:variable name="document_allSections" select="/page/pageResponse/document//documentNode[@nodeType!='root']" />
335
336<xsl:variable name="document_topLevelNodes" select="/page/pageResponse/document/documentNode/documentNode" />
337
338
339<xsl:variable name="document_topLevelSections" select="/page/pageResponse/document/documentNode/documentNode" />
340
341<xsl:template name="document_section_id">
342 <xsl:value-of select="./@nodeID"/>
343</xsl:template>
344
345<xsl:template name="document_section_title">
346 <xsl:value-of disable-output-escaping='yes' select="./metadataList/metadata[@name='Title']"/>
347</xsl:template>
348
349<xsl:template name="document_section_depth">
350 <xsl:value-of select="count(./ancestor::documentNode)"/>
351</xsl:template>
352
353<xsl:template name="document_section_content">
354 <xsl:value-of disable-output-escaping='yes' select="./nodeContent"/>
355</xsl:template>
356
357
358<xsl:variable name="document_currentSection" select="/page/pageResponse/document//nodeContent/.." />
359
360<xsl:variable name="document_currentSection_title" select="$document_currentSection/metadataList/metadata[@name='Title']" />
361
362<xsl:variable name="document_currentSection_content">
363 <xsl:value-of disable-output-escaping='yes' select="$document_currentSection/nodeContent" />
364</xsl:variable>
365
366<xsl:variable name="document_previousSection" select="$document_currentSection/preceding::documentNode[@nodeType='leaf'][1]"/>
367
368<xsl:variable name="document_previousSection_title" select="$document_previousSection/metadataList/metadata[@name='Title']"/>
369
370<xsl:variable name="document_previousSection_url">
371<xsl:value-of select="$librarian"/>?a=d&amp;
372c=<xsl:value-of select="$collection"/>&amp;
373d=<xsl:value-of select="$document_previousSection/@nodeID"/>&amp;
374sib=1&amp;
375ec=1
376</xsl:variable>
377
378<xsl:variable name="document_nextSection" select="$document_currentSection/following::documentNode[@nodeType='leaf'][1]"/>
379
380<xsl:variable name="document_nextSection_title" select="$document_nextSection/metadataList/metadata[@name='Title']"/>
381
382<xsl:variable name="document_nextSection_url">
383<xsl:value-of select="$librarian"/>?a=d&amp;
384c=<xsl:value-of select="$collection"/>&amp;
385d=<xsl:value-of select="$document_nextSection/@nodeID"/>&amp;
386sib=1&amp;
387ec=1
388</xsl:variable>
389
390<xsl:variable name="document_ancestorSections" select="$document_currentSection/ancestor::documentNode[@nodeType='internal']"/>
391
392<xsl:variable name="document_ancestorSections_titles" select="$document_ancestorSections/metadataList/metadata[@name='Title']"/>
393
394
395
396
397
398
399
400
401<!-- stuff that no-one should need to know about........................................ -->
402
403<!-- produce an exact copy of the current node, but expand and replace all metadataItems and uiItems found within. -->
404<xsl:template name="expandMetadataAndUiItems">
405 <xsl:for-each select="*|text()">
406 <xsl:choose>
407
408 <!-- if node is a metadataItem, expand it -->
409 <xsl:when test="self::node()[self::metadataItem]">
410 <xsl:call-template name="metadataItem">
411 <xsl:with-param name="name"><xsl:value-of select="@name" disable-output-escaping="yes"/></xsl:with-param>
412 </xsl:call-template>
413 </xsl:when>
414
415 <!-- if node is a uiItem, expand it -->
416 <xsl:when test="self::node()[self::uiItem]">
417 <xsl:call-template name="uiItem">
418 <xsl:with-param name="name"><xsl:value-of select="@name" disable-output-escaping="yes"/></xsl:with-param>
419 </xsl:call-template>
420 </xsl:when>
421
422 <xsl:when test="self::text()">
423 <xsl:value-of select="." disable-output-escaping="yes"/>
424 </xsl:when>
425
426 <!-- if a regular node -->
427 <xsl:otherwise>
428 <xsl:variable name="element-name" select="name()"/>
429 <xsl:element name="{$element-name}">
430 <xsl:for-each select="@*">
431 <xsl:variable name="attribute-name" select="name()"/>
432 <xsl:attribute name="{$attribute-name}">
433 <xsl:call-template name="attribute-filter"/>
434 </xsl:attribute>
435 </xsl:for-each>
436 <xsl:call-template name="expandMetadataAndUiItems" />
437 </xsl:element>
438 </xsl:otherwise>
439 </xsl:choose>
440 </xsl:for-each>
441
442</xsl:template>
443
444<xsl:template name="attribute-filter"><xsl:value-of select="."/></xsl:template>
445
446</xsl:stylesheet>
447
448
Note: See TracBrowser for help on using the repository browser.