source: main/trunk/greenstone3/web/interfaces/default/transform/expand-gsf.xsl@ 36528

Last change on this file since 36528 was 36528, checked in by kjdon, 20 months ago

only display a line in metadata-table if there is a metadata value. or if show_if_empty = true

File size: 31.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:xslt="output.xsl"
5 xmlns:java="http://xml.apache.org/xslt/java"
6 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
7 xmlns:xalan="http://xml.apache.org/xalan"
8 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
9 extension-element-prefixes="java xalan">
10
11 <xsl:param name="interface_name"/>
12 <xsl:param name="library_name"/>
13 <xsl:param name="site_name"/>
14 <xsl:param name="use_client_side_xslt"/>
15 <xsl:param name="collName"/>
16 <xsl:param name="lang"/>
17
18 <xsl:output method="xml"/>
19 <xsl:namespace-alias stylesheet-prefix="xslt" result-prefix="xsl"/>
20
21 <!-- don't output anything for gsf:format-gs2 elements,
22 they just exist in collectionconfig files to keep the XML valid -->
23 <xsl:template match="gsf:format-gs2" />
24
25 <xsl:template match="format">
26 <format>
27 <xsl:apply-templates/>
28 </format>
29 </xsl:template>
30
31 <xsl:template match="gsf:template">
32 <xslt:template>
33 <xsl:copy-of select="@*"/>
34 <xsl:attribute name="priority">2</xsl:attribute>
35 <xsl:if test=".//gsf:link">
36 <xslt:param name="serviceName"/>
37 <xslt:param name="collName"/>
38 </xsl:if>
39 <xsl:apply-templates/>
40 </xslt:template>
41 </xsl:template>
42
43 <xsl:template match="gsf:variable">
44 <xslt:variable>
45 <xsl:copy-of select="@*"/>
46 <xsl:apply-templates/>
47 </xslt:variable>
48 <script type="text/javascript">
49 gs.variables.<xsl:value-of select="@name"/>
50 <xslt:text disable-output-escaping="yes"> = "</xslt:text>
51 <xsl:apply-templates/>
52 <xslt:text disable-output-escaping="yes">";</xslt:text>
53 </script>
54 </xsl:template>
55
56
57 <xsl:template match="gsf:variable2">
58 <xslt:variable>
59 <xsl:copy-of select="@*"/>
60 <xsl:apply-templates/>
61 </xslt:variable>
62 <script type="text/javascript">
63 gs.variables.<xsl:value-of select="@name"/>
64 <xslt:text disable-output-escaping="yes"> = '</xslt:text>
65 <xsl:apply-templates/>
66 <xslt:text disable-output-escaping="yes">';</xslt:text>
67 </script>
68 </xsl:template>
69
70 <xsl:template match="gsf:defaultClassifierNode">
71 <xslt:call-template name="defaultClassifierNode"/>
72 </xsl:template>
73
74
75 <xsl:template match="gsf:script[@src]">
76 <script>
77 <xsl:attribute name='src'>
78 <xsl:value-of select="@src"/>
79 </xsl:attribute>
80 <xslt:attribute name='type'>text/javascript</xslt:attribute>
81 <xslt:comment/>
82 <!-- comment used to ensure script tag is not collapsed -->
83 </script>
84 </xsl:template>
85
86
87 <xsl:template match="gsf:script">
88 <script type="text/javascript">
89 <xslt:text disable-output-escaping="yes">
90 <xsl:apply-templates/>
91 </xslt:text>
92 </script>
93 </xsl:template>
94
95 <xsl:template match="gsf:style[@src]">
96 <link rel="stylesheet" type="text/css">
97 <xsl:attribute name='href'>
98 <xsl:value-of select="@src"/>
99 </xsl:attribute>
100 </link>
101 </xsl:template>
102
103 <xsl:template match="gsf:style">
104 <style type="text/css">
105 <xsl:apply-templates/>
106 </style>
107 </xsl:template>
108
109 <!-- a template for 'div' that doesn't trigger the
110 self-closing problem when being rendered as HTML by using
111 xslt:value-of="''" to ensure element doesn't become empty
112 when the XSLT processes it (which would then result in it
113 being changed into a self-closing element, which then is
114 incorrectly rendered as HTML). Doing this with the
115 value-of is better then injecting an xsl:comment in
116 (another approach we have used in the past) as the
117 comment approach then actually turns up in the final
118 HTML. This can lead to further complications if
119 Javascript using the 'empty' div truely expects it to
120 have no content of any form.
121 -->
122
123 <xsl:template match="gsf:div">
124 <div>
125 <xsl:for-each select="@*">
126 <xsl:attribute name="{name()}">
127 <xsl:value-of select="."/>
128 </xsl:attribute>
129 </xsl:for-each>
130 <xsl:apply-templates/>
131 <xslt:value-of select="''" /> <!-- to ensure that the div tag does not collapse into one of the form <div/> -->
132 </div>
133 </xsl:template>
134
135 <xsl:template match="gsf:dquote"><xslt:text disable-output-escaping="yes">"</xslt:text></xsl:template>
136 <!--
137 While double-quotes do map to entities in HTML, technically single quotes don't need to go through
138 this process: they can just be typed literally, and so this means there isn't strictly a need
139 for the following rule, but included for completeness. A long time ago it might have been that IE
140 did need the character to be entity-mapped -->
141 <xsl:template match="gsf:squote"><xslt:text disable-output-escaping="yes">'</xslt:text></xsl:template>
142
143 <xsl:template match="gsf:image">
144 <xslt:variable name="metaName">
145 <xsl:choose>
146 <xsl:when test="@type = 'thumb'">Thumb</xsl:when>
147 <xsl:when test="@type = 'screen'">Screen</xsl:when>
148 <xsl:when test="@type = 'source'">SourceFile</xsl:when>
149 <xsl:when test="@type = 'cover'">root_hascover</xsl:when>
150 </xsl:choose>
151 </xslt:variable>
152 <xslt:variable name="thisAssocfilepath">
153 <xslt:choose>
154 <xslt:when test="/page/pageResponse/document">
155 <xslt:choose>
156 <xslt:when test="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']">
157 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']" />
158 </xslt:when>
159 <xslt:otherwise>
160 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode[@nodeType='root']/metadataList/metadata[@name='assocfilepath']" />
161 </xslt:otherwise>
162 </xslt:choose>
163 </xslt:when>
164 <xslt:otherwise>
165 <xslt:choose>
166 <xslt:when test="(.//metadataList)[last()]/metadata[@name='assocfilepath']">
167 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='assocfilepath']" />
168 </xslt:when>
169 <xslt:otherwise>
170 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='root_assocfilepath']" />
171 </xslt:otherwise>
172 </xslt:choose>
173 </xslt:otherwise>
174 </xslt:choose>
175 </xslt:variable>
176 <xslt:if test="./metadataList/metadata[@name = $metaName]">
177 <img>
178 <xslt:attribute name='src'>
179 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
180 <xsl:text>/index/assoc/</xsl:text><xslt:value-of disable-output-escaping="yes" select="$thisAssocfilepath" /><xsl:text>/</xsl:text>
181 <xslt:choose>
182 <xslt:when test="$metaName = 'root_hascover'">cover.jpg</xslt:when>
183 <xslt:otherwise>
184 <xslt:value-of disable-output-escaping="yes" select="./metadataList/metadata[@name = $metaName]"/>
185 </xslt:otherwise>
186 </xslt:choose>
187 </xslt:attribute>
188 <!-- copy any other attributes apart from type-->
189 <xsl:for-each select="@*[name() != 'type']">
190 <xslt:attribute name="{name()}">
191 <xsl:value-of select="."/>
192 </xslt:attribute>
193 </xsl:for-each>
194
195 </img>
196 </xslt:if>
197 </xsl:template>
198
199 <!-- make this empty so we don't process the params element again inside the gsf:link type=query-->
200 <xsl:template match="params"></xsl:template>
201
202 <xsl:template match="gsf:collectionPath">
203 <xslt:value-of select='$library_name'/>
204 <xsl:text>/collection/</xsl:text>
205 <xslt:value-of select='/page/pageResponse/collection/@name'/>
206 </xsl:template>
207
208 <xsl:template match="gsf:link">
209
210 <xslt:variable name="collNameLocal" select="/page/pageResponse/collection/@name"/>
211 <xsl:variable name="opt-title">
212 <xsl:choose>
213 <xsl:when test="@title">
214 <xslt:attribute name="title">
215 <xsl:value-of select="@title"/>
216 </xslt:attribute>
217 </xsl:when>
218 <xsl:when test="@titlekey">
219 <xslt:attribute name="title">
220 <xslt:value-of disable-output-escaping="yes" select="util:getCollectionText($collNameLocal, $site_name, /page/@lang, '{@titlekey}')"/>
221 </xslt:attribute>
222 </xsl:when>
223 </xsl:choose>
224 </xsl:variable>
225
226 <xsl:choose>
227 <xsl:when test="@type='query'">
228 <a>
229 <xsl:if test="@target">
230 <xsl:attribute name='target'>
231 <xsl:value-of select='@target'/>
232 </xsl:attribute>
233 </xsl:if>
234
235 <xslt:attribute name='href'>
236 <xslt:value-of select='$library_name'/>
237 <xsl:text>/collection/</xsl:text>
238 <xslt:value-of select='/page/pageResponse/collection/@name'/>
239 <xsl:text>/search/</xsl:text>
240 <xsl:choose>
241 <xsl:when test="@name">
242 <xsl:value-of select="@name"/>
243 </xsl:when>
244 <xsl:otherwise>
245 <xsl:text>TextQuery</xsl:text>
246 </xsl:otherwise>
247 </xsl:choose>
248 <xsl:for-each select="params">?rt=rd&amp;<xsl:apply-templates/></xsl:for-each>
249
250 </xslt:attribute>
251 <xsl:copy-of select="$opt-title"/>
252 <xsl:apply-templates/>
253 </a>
254 </xsl:when>
255 <xsl:when test="@type='classifier'">
256 <a>
257 <xsl:if test="@target">
258 <xsl:attribute name='target'>
259 <xsl:value-of select='@target'/>
260 </xsl:attribute>
261 </xsl:if>
262
263 <xslt:attribute name='href'><xslt:call-template name="classifierNodeLink"><xsl:if test="@style"><xslt:with-param name="link-type"><xsl:value-of select="@style"/></xslt:with-param></xsl:if><xsl:if test="@nodeID"><xslt:with-param name="node-id"><xsl:value-of select="@nodeID"/></xslt:with-param></xsl:if></xslt:call-template>
264 </xslt:attribute>
265 <xsl:copy-of select="$opt-title"/>
266 <xsl:apply-templates/>
267 </a>
268 </xsl:when>
269 <xsl:when test="@type='source'">
270 <xslt:variable name="thisAssocfilepath">
271 <xslt:choose>
272 <xslt:when test="/page/pageResponse/document">
273 <xslt:choose>
274 <xslt:when test="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']">
275 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']" />
276 </xslt:when>
277 <xslt:otherwise>
278 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode[@nodeType='root']/metadataList/metadata[@name='assocfilepath']" />
279 </xslt:otherwise>
280 </xslt:choose>
281 </xslt:when>
282 <xslt:otherwise>
283 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='root_assocfilepath']" />
284 </xslt:otherwise>
285 </xslt:choose>
286 </xslt:variable>
287 <xsl:variable name="image_meta">
288 <xsl:choose>
289 <xsl:when test="@source_meta"><xsl:value-of select="@source_meta"/>
290 </xsl:when>
291 <xsl:otherwise>srclinkFile</xsl:otherwise>
292 </xsl:choose>
293 </xsl:variable>
294 <a>
295 <xsl:if test="@target">
296 <xsl:attribute name='target'>
297 <xsl:value-of select='@target'/>
298 </xsl:attribute>
299 </xsl:if>
300 <xsl:if test="@download">
301 <xsl:attribute name='download'>
302 <xsl:value-of select='@download'/>
303 </xsl:attribute>
304 </xsl:if>
305 <xslt:attribute name='href'>
306 <xslt:value-of
307 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
308 disable-output-escaping="yes" select="$thisAssocfilepath" />/<xslt:value-of
309 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='{$image_meta}']" />
310 </xslt:attribute>
311 <xsl:copy-of select="$opt-title"/>
312 <xsl:apply-templates/>
313 </a>
314 </xsl:when>
315 <xsl:when test="@type='web'">
316 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='weblink']"/>
317 <xsl:apply-templates/>
318 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='/weblink']"/>
319 </xsl:when>
320 <xsl:when test="@type='page'">
321 <a>
322 <xsl:if test="@target">
323 <xsl:attribute name='target'>
324 <xsl:value-of select='@target'/>
325 </xsl:attribute>
326 </xsl:if>
327
328 <xslt:attribute name='href'>
329 <xslt:value-of select='$library_name'/>
330 <xsl:text>/collection/</xsl:text>
331 <xslt:value-of select='/page/pageResponse/collection/@name'/>
332 <xsl:text>/page/</xsl:text>
333 <xsl:value-of select="@page"/>
334 </xslt:attribute>
335 <xsl:copy-of select="$opt-title"/>
336 <xsl:apply-templates/>
337 </a>
338 </xsl:when>
339 <xsl:when test="@type='equivdoc'">
340 <xsl:call-template name="gsf:equivlinkgs3"/>
341 </xsl:when>
342 <xsl:when test="@type='rss'">
343 <a>
344 <xslt:attribute name='href'>
345 <xslt:value-of select='$library_name'/>
346 <xsl:text>?a=rss&amp;l=en&amp;site=</xsl:text>
347 <xslt:value-of select="$site_name"/>
348 <xsl:text>&amp;c=</xsl:text>
349 <xslt:value-of select='/page/pageResponse/collection/@name'/>
350 </xslt:attribute>
351 <xsl:apply-templates/>
352 </a>
353 </xsl:when>
354 <xsl:otherwise>
355 <!-- a document link -->
356 <xslt:variable name="bookswitch">
357 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
358 </xslt:variable>
359
360 <a>
361 <xsl:if test="@target">
362 <xsl:attribute name='target'>
363 <xsl:value-of select='@target'/>
364 </xsl:attribute>
365 </xsl:if>
366
367 <xsl:copy-of select="$opt-title"/>
368 <xslt:attribute name="href">
369 <xslt:value-of select='$library_name'/>
370 <xsl:text>/collection/</xsl:text>
371 <xslt:value-of select='/page/pageResponse/collection/@name'/>
372 <xsl:text>/document/</xsl:text>
373 <xsl:choose>
374 <xsl:when test="@OID">
375 <xsl:value-of select="@OID"/>
376 </xsl:when>
377 <xsl:when test="@OIDmetadata">
378 <xsl:variable name="OIDmeta" select="@OIDmetadata"/>
379 <xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$OIDmeta}']"/>
380 </xsl:when>
381 <xsl:otherwise>
382 <xslt:value-of select='@nodeID'/>
383 </xsl:otherwise>
384 </xsl:choose>
385 <xslt:choose>
386 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
387 <xsl:text>?book=on</xsl:text>
388 </xslt:when>
389 <xslt:otherwise>
390 <xslt:if test="$opt-doc-link-args">?<xslt:value-of select="$opt-doc-link-args"/>
391 </xslt:if>
392 </xslt:otherwise>
393 </xslt:choose>
394 </xslt:attribute>
395 <xsl:apply-templates/>
396 </a>
397 </xsl:otherwise>
398 </xsl:choose>
399 </xsl:template>
400
401 <xsl:template match="gsf:OID">
402 <xslt:value-of select="@nodeID"/>
403 </xsl:template>
404 <xsl:template match="gsf:rank">
405 <xslt:value-of select="@rank"/>
406 </xsl:template>
407 <xsl:template match="gsf:icon">
408 <xsl:choose>
409 <xsl:when test="@type='classifier'">
410 <img style="border:0px">
411 <xsl:attribute name="src">
412 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/>
413 </xsl:attribute>
414 </img>
415 </xsl:when>
416 <xsl:when test="@type='web'">
417 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, 'webicon')]"/>
418 </xsl:when>
419 <xsl:when test="@file">
420 <img>
421 <xslt:attribute name='src'>
422 <xsl:choose>
423 <xsl:when test="not(@select) or @select='site'">
424 <xsl:value-of disable-output-escaping="yes" select="concat('interfaces/',$interface_name,'/images/',@file)"/>
425 </xsl:when>
426 <xsl:when test="@select='collection'">
427 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>
428 <xsl:value-of disable-output-escaping="yes" select="concat('/images/',@file)"/>
429 </xsl:when>
430 </xsl:choose>
431 </xslt:attribute>
432 <xsl:if test="@alt">
433 <xslt:attribute name='alt'>
434 <xsl:value-of select="@alt" />
435 </xslt:attribute>
436 </xsl:if>
437 </img>
438 </xsl:when>
439 <xsl:when test="not(@type) or @type='document'">
440 <img style="border:0px">
441 <xslt:attribute name="id">documentBasketBook<xslt:value-of select="/page/pageResponse/collection/@name"/>:<xslt:value-of select="@nodeID"/>
442 </xslt:attribute>
443 <xslt:attribute name="src">
444 <xslt:choose>
445 <xslt:when test="@docType='hierarchy' and @nodeType='root'">
446 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/>
447 </xslt:when>
448 <xslt:otherwise>
449 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/>
450 </xslt:otherwise>
451 </xslt:choose>
452 </xslt:attribute>
453 </img>
454 </xsl:when>
455 </xsl:choose>
456 </xsl:template>
457
458 <!-- calls a template in gslib.xsl in order to avoid xsl vs xslt issue -->
459 <!--<xsl:template match="gsf:equivlinkgs3">
460 <xslt:call-template name="equivDocLinks">
461 <xslt:with-param name="count" select="0"/>
462 </xslt:call-template>
463 </xsl:template>-->
464
465 <!-- Another way (also works with DSpace tutorial): build all the equivalent document links for the current document in one go. No looping necessary: handled in function call. -->
466 <xsl:template match="gsf:equivlinkgs3" name="gsf:equivlinkgs3">
467 <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>
468 <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>
469 <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/>
470
471 <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" />
472 <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/>
473 </xsl:template>
474
475 <!--
476In the collection's format statement, could have the following javascript+XSLT in place of
477the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and gslib.xsl).
478<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot;
479</xsl:text>
480<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/>
481<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot;
482</xsl:text>
483<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/>
484<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot;
485</xsl:text>
486<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/>
487<xsl:text disable-output-escaping="yes">&quot;];for (var i=0; i&lt;equivDocIcon.length; i++) { document.write(equivDocStartLink[i]+ equivDocIcon[i] + equivDocEndLink[i]); }&lt;/script&gt;
488</xsl:text>
489-->
490
491 <!-- gsf:cgiparam example, as used by the Enhanced PDF tutorial:
492 <a><xsl:attribute name="href"><gsf:metadata name="httpPath" type="collection"/>/index/assoc/<gsf:metadata name="archivedir"/>/<gsf:metadata name="srclinkFile"/>#search=&amp;quot;<gsf:cgi-param name="query"/>&amp;quot;</xsl:attribute>src doc link with query highlighting</a> -->
493 <xsl:template match="gsf:cgi-param">
494 <xslt:value-of disable-output-escaping="yes" select="/page/pageRequest/paramList/param[@name='s1.{@name}']/@value"/>
495 </xsl:template>
496
497 <!-- A GLI user can use a gsf:displayText element in GS3's Format Features to retrieve
498 a string defined in either collectionConfig.xml or else the interface dictionaries.
499 If the requested string occurs in neither, the request string itself will be output. -->
500 <xsl:template match="gsf:displayText">
501 <xslt:variable name="displaytext">
502 <xsl:call-template name="gsf:displayItem"/>
503 </xslt:variable>
504
505 <xslt:choose>
506 <xslt:when test="$displaytext != ''">
507 <xslt:value-of disable-output-escaping="yes" select="$displaytext"/>
508 </xslt:when>
509 <xslt:otherwise>
510 <xslt:variable name="interfacetxt">
511 <xsl:call-template name="gsf:interfaceText"/>
512 </xslt:variable>
513
514 <xslt:choose>
515 <xslt:when test="$interfacetxt != ''">
516 <xslt:value-of disable-output-escaping="yes" select="$interfacetxt"/>
517 </xslt:when>
518 <xslt:otherwise>
519 <xslt:value-of disable-output-escaping="yes" select="'{@name}'"/>
520 </xslt:otherwise>
521 </xslt:choose>
522 </xslt:otherwise>
523 </xslt:choose>
524 </xsl:template>
525
526 <!-- With gsf:displayItem, a user can request a displayItem from collectionConfig.xml -->
527 <xsl:template match="gsf:displayItem" name="gsf:displayItem">
528 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/displayItemList/displayItem[@name='{@name}']"/>
529 </xsl:template>
530
531 <!-- With gsf:interfaceText, a user can request a string from the interface dictionaries in the current lang -->
532 <xsl:template match="gsf:interfaceText" name="gsf:interfaceText">
533 <xsl:choose>
534 <xsl:when test="@propertyFile">
535 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, '{@propertyFile}', /page/@lang, '{@name}', '')"/>
536 </xsl:when>
537 <xsl:otherwise>
538 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, /page/@lang, '{@name}')"/>
539 </xsl:otherwise>
540 </xsl:choose>
541 </xsl:template>
542
543 <!-- With gsf:collectionText, a user can request a string from the collection's dictionary in the current lang -->
544 <xsl:template match="gsf:collectionText1" name="gsf:collectionText1">
545 <xslt:variable name="collName" select="/page/pageResponse/collection/@name"/>
546 <xslt:copy-of select="util:getCollectionText($collName, $site_name, /page/@lang, '{@name}', '{@args}')/node()"/>
547 </xsl:template>
548 <xsl:template match="gsf:collectionText" name="gsf:collectionText">
549 <xsl:copy-of select="util:getCollectionText($collName, $site_name, $lang, @name, @args)/node()"/>
550 </xsl:template>
551
552
553 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
554 <xsl:template match="gsf:metadata">
555 <xsl:if test="not(@hidden = 'true')">
556 <!-- set hidden=true on a gsf:metadata so that it gets retrieved from the server but not displayed -->
557 <xsl:variable name="meta_test"><xsl:call-template name="getMetadataTest"/></xsl:variable>
558 <xsl:variable name="separator">
559 <xsl:choose>
560 <xsl:when test="@separator">
561 <xsl:choose>
562 <xsl:when test="@separator = ' '">
563 <!-- http://stackoverflow.com/questions/1461649/how-to-insert-nbsp-in-xslt -->
564 <xsl:text>&#160;</xsl:text>
565 <!--<xsl:text> </xsl:text> only works in GLI's Format panel-->
566 <!--<xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>-->
567 </xsl:when>
568 <xsl:otherwise>
569 <xsl:value-of disable-output-escaping='yes' select="@separator"/>
570 </xsl:otherwise>
571 </xsl:choose>
572 </xsl:when>
573 <xsl:when test="separator">
574 <xsl:copy-of select="separator/node()"/>
575 </xsl:when>
576 <xsl:otherwise>
577 <xsl:text>, </xsl:text>
578 </xsl:otherwise>
579 </xsl:choose>
580 </xsl:variable>
581 <xsl:variable name="prefix">
582 <xsl:choose>
583 <xsl:when test="@prefix">
584 <xsl:value-of disable-output-escaping='yes' select="@prefix"/>
585 </xsl:when>
586 <xsl:when test="prefix">
587 <xsl:copy-of select="prefix/node()"/>
588 </xsl:when>
589 </xsl:choose>
590 </xsl:variable>
591 <xsl:variable name="suffix">
592 <xsl:choose>
593 <xsl:when test="@suffix">
594 <xsl:value-of disable-output-escaping='yes' select="@suffix"/>
595 </xsl:when>
596 <xsl:when test="suffix">
597 <xsl:copy-of select="suffix/node()"/>
598 </xsl:when>
599 </xsl:choose>
600 </xsl:variable>
601 <xsl:variable name="postest">
602 <xsl:choose>
603 <xsl:when test="@pos = 'first'">position()=1</xsl:when>
604 <xsl:when test="@pos = 'last'">position() = last()</xsl:when>
605 <xsl:when test="@pos = 'classifiedBy'">position() = number(../../@mdoffset)+1</xsl:when>
606 <xsl:when test="@pos">position() = <xsl:value-of select="@pos"/>
607 </xsl:when>
608 <xsl:otherwise>true()</xsl:otherwise>
609 </xsl:choose>
610 </xsl:variable>
611 <xsl:variable name="multiple">
612 <xsl:choose>
613 <xsl:when test="@pos">false()</xsl:when>
614 <xsl:otherwise>true()</xsl:otherwise>
615 </xsl:choose>
616 </xsl:variable>
617 <xslt:for-each>
618 <xsl:attribute name="select">
619 (<xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>.//metadataList)[last()]/metadata[<xsl:value-of select="$meta_test"/><xsl:if test="@lang">
620 <xsl:text> and @lang=</xsl:text>
621 <xsl:value-of select="@lang"/>
622 </xsl:if>
623 <xsl:text>]</xsl:text>
624 </xsl:attribute>
625 <xslt:if test="{$postest}">
626 <xslt:if test="{$multiple} and position()>1"><xsl:copy-of select="$separator"/>
627 </xslt:if>
628 <xsl:copy-of select="$prefix"/>
629 <xsl:choose>
630 <xsl:when test="@format">
631 <xslt:value-of disable-output-escaping='yes' select="util:{@format}(., /page/@lang )"/>
632 </xsl:when>
633 <xsl:when test="@highlight"><xslt:call-template name="displayMarkedUpTextAndAnnotations"/>
634 </xsl:when>
635 <xsl:otherwise>
636 <xslt:value-of disable-output-escaping='yes' select="."/>
637 </xsl:otherwise>
638 </xsl:choose>
639 </xslt:if>
640 <xsl:copy-of select="$suffix"/>
641 </xslt:for-each>
642 </xsl:if>
643 </xsl:template>
644
645
646 <xsl:template match="gsf:foreach-metadata">
647 <xsl:variable name="meta_name"><xsl:call-template name="getMetadataName"/></xsl:variable>
648 <xslt:for-each>
649 <xsl:attribute name="select">
650 (<xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>.//metadataList)[last()]/metadata[@name='<xsl:value-of select="$meta_name"/>'<xsl:if test="@lang"><xsl:text> and @lang=</xsl:text><xsl:value-of select="@lang"/></xsl:if><xsl:text>]</xsl:text>
651 </xsl:attribute><xsl:choose><xsl:when test='@sort'><xslt:sort/></xsl:when><xsl:when test="gsf:sort"><xslt:sort><xsl:copy-of select="gsf:sort/@*"/></xslt:sort></xsl:when></xsl:choose><xsl:if test='@separator'><xslt:if test='position()>1'><xsl:value-of select='@separator'/></xslt:if></xsl:if>
652 <xsl:apply-templates/>
653 </xslt:for-each>
654 </xsl:template>
655
656 <xsl:template match="gsf:meta-value">
657 <xslt:value-of disable-output-escaping="yes" select="."/>
658 </xsl:template>
659
660 <xsl:template name="getMetadataName">
661 <xsl:if test='@select'>
662 <xsl:value-of select='@select'/>
663 <xsl:text>_</xsl:text>
664 </xsl:if>
665 <xsl:call-template name="stripEx"><xsl:with-param name="meta-name" select="@name"/></xsl:call-template>
666 </xsl:template>
667
668 <!-- we allow ex.Title in gsf:metadata. Need to strip off the ex. as the metadata in the database will be just Title. However, metadata like ex.dc.Title does keep its ex. in the database, so don't remove ex. if there is another . in the name -->
669 <xsl:template name="stripEx">
670 <xsl:param name="meta-name"/>
671 <xsl:choose><xsl:when test="starts-with($meta-name, 'ex.') and not(contains(substring($meta-name, 4), '.'))"><xsl:value-of select="substring($meta-name, 4)"/></xsl:when><xsl:otherwise><xsl:value-of select="$meta-name"/></xsl:otherwise></xsl:choose>
672 </xsl:template>
673
674 <!-- if we have metadata name="dc.Date,Date" will make a test like (@name = 'dc.Date' or @name = 'Date') -->
675 <xsl:template name="getMetadataTest">
676 <xsl:variable name="selectattr"><xsl:value-of select='@select'/></xsl:variable>
677 (<xsl:for-each select="xalan:tokenize(@name, ',')"><xsl:if test="position()!=1"> or </xsl:if>@name='<xsl:if test="$selectattr != ''"><xsl:value-of select="$selectattr"/><xsl:text>_</xsl:text></xsl:if><xsl:call-template name="stripEx"><xsl:with-param name="meta-name"><xsl:value-of select="."/></xsl:with-param></xsl:call-template>'</xsl:for-each>)
678 </xsl:template>
679
680 <xsl:template match="gsf:metadata-table">
681 <table class="metadataTable">
682 <tbody>
683 <xsl:for-each select="gsf:metadata">
684
685 <xsl:variable name="meta-path">(./metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']<xsl:if test="@pos">[<xsl:value-of select="@pos"/>]</xsl:if></xsl:variable>
686
687 <xslt:if><xsl:attribute name="test"><xsl:choose><xsl:when test="@show-if-empty='true'">true()</xsl:when><xsl:otherwise><xsl:value-of select="$meta-path"/></xsl:otherwise></xsl:choose></xsl:attribute>
688 <tr>
689 <td>
690 <xsl:choose>
691 <xsl:when test="./displayItem">
692 <xslt:variable name="di_list"><di_list><xsl:copy-of select="./displayItem"/></di_list></xslt:variable>
693 <xslt:value-of select="util:getCollectionDisplayItemText($di_list, /page/@lang, $site_name, $collName )"/>
694 </xsl:when>
695 <!-- just copy out the text content-->
696 <xsl:otherwise>
697 <xsl:value-of select="."/>
698 </xsl:otherwise>
699 </xsl:choose>
700 </td>
701 <td>
702 <xsl:choose>
703 <xsl:when test="./content"><xsl:copy-of select="./content"/></xsl:when>
704 <xsl:otherwise>
705 <i><xsl:copy-of select="."/></i>
706 </xsl:otherwise>
707 </xsl:choose>
708 </td>
709 </tr>
710 </xslt:if>
711 </xsl:for-each>
712
713 </tbody>
714 </table>
715 </xsl:template>
716
717 <xsl:template match="gsf:text">
718 <xsl:variable name="force">
719 <xsl:choose><xsl:when test="@force = 'true'">1</xsl:when><xsl:when test="@force = 'false'">0</xsl:when><xsl:otherwise>0</xsl:otherwise></xsl:choose>
720 </xsl:variable>
721 <xslt:call-template name="documentNodeText"><xslt:with-param name="force"><xsl:value-of select="$force"/></xslt:with-param></xslt:call-template>
722 </xsl:template>
723
724 <xsl:template match="gsf:if-metadata-exists">
725 <xsl:variable name="meta-path">
726 <xsl:for-each select="gsf:metadata">(./metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']<xsl:if test="@pos">[<xsl:value-of select="@pos"/>]</xsl:if></xsl:for-each>
727 </xsl:variable>
728 <xslt:choose>
729 <xslt:when test="{$meta-path}">
730 <xsl:apply-templates select="gsf:if/node()"/>
731 </xslt:when>
732 <xsl:if test="gsf:else">
733 <xslt:otherwise>
734 <xsl:apply-templates select="gsf:else/node()"/>
735 </xslt:otherwise>
736 </xsl:if>
737 </xslt:choose>
738 </xsl:template>
739
740 <xsl:template match="gsf:choose-metadata">
741 <xslt:choose>
742 <xsl:for-each select="gsf:metadata">
743 <xslt:when>
744 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:attribute>
745 <xsl:apply-templates select="."/>
746 </xslt:when>
747 </xsl:for-each>
748 <xsl:if test="gsf:default">
749 <xslt:otherwise>
750 <xsl:apply-templates select="gsf:default/node()"/>
751 </xslt:otherwise>
752 </xsl:if>
753 </xslt:choose>
754 </xsl:template>
755
756 <xsl:template match="gsf:switch">
757 <xsl:variable name="meta-name">
758 <xsl:for-each select="gsf:metadata">
759 <xsl:call-template name="getMetadataName"/>
760 </xsl:for-each>
761 </xsl:variable>
762 <xslt:variable name="meta">
763 <xsl:choose>
764 <xsl:when test="@preprocess">
765 <xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'], /page/@lang )"/>
766 </xsl:when>
767 <xsl:otherwise>
768 <xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/>
769 </xsl:otherwise>
770 </xsl:choose>
771 </xslt:variable>
772 <xslt:choose>
773 <xsl:for-each select="gsf:when">
774 <xslt:when test="util:{@test}($meta, '{@test-value}')">
775 <xsl:apply-templates/>
776 </xslt:when>
777 </xsl:for-each>
778 <xsl:if test="gsf:otherwise">
779 <xslt:otherwise>
780 <xsl:apply-templates select="gsf:otherwise/node()"/>
781 </xslt:otherwise>
782 </xsl:if>
783 </xslt:choose>
784 </xsl:template>
785
786 <!--
787 <gsf:headMetaTags> exists for controlling the <meta name="x" content="y"> elements that appear in the HTML <head></head>
788 XPATH is used to select this item (in header.xsl). It does not need an explicit definition here in this file
789 -->
790 <!-- this template is used to avoid the user having to type
791 <xsl:text disable-output-escaping="yes">..</xsl:text> when they are trying to add unbalanced html tags into the xml (eg using suffix and prefix with metadata display -->
792 <xsl:template match="gsf:html">
793 <xslt:text disable-output-escaping="yes"><xsl:value-of select="."/></xslt:text>
794 </xsl:template>
795 <!-- use this if you want a space after an element in the output.
796 e.g. <strong>Title:><gsf:space/></strong -->
797 <xsl:template match="gsf:space">&#160;</xsl:template>
798 <xsl:template match="*">
799 <xsl:copy>
800 <xsl:copy-of select="@*"/>
801 <xsl:apply-templates/>
802 </xsl:copy>
803 </xsl:template>
804
805</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.