source: greenstone3/branches/customizingGreenstone3/web/ui/xslt/library.xsl@ 14712

Last change on this file since 14712 was 14712, checked in by dnk2, 17 years ago

dump of existing code

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