source: main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl@ 32442

Last change on this file since 32442 was 32442, checked in by kjdon, 6 years ago

if using <gsf:image type='cover'> in search results format statement, then we have assocfilepath in metadata (assuming doc level) not root_assocfilepath. so try both.

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