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

Last change on this file since 31656 was 31656, checked in by kjdon, 7 years ago

fixed up the nodeId parameter passing to classifierNodeLink. Didn't work the way I had it.

File size: 26.8 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:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']" />
146 </xslt:when>
147 <xslt:otherwise>
148 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='root_assocfilepath']" />
149 </xslt:otherwise>
150 </xslt:choose>
151 </xslt:variable>
152 <xslt:if test="./metadataList/metadata[@name = $metaName]">
153 <img>
154 <xslt:attribute name='src'>
155 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
156 <xsl:text>/index/assoc/</xsl:text><xslt:value-of disable-output-escaping="yes" select="$thisAssocfilepath" /><xsl:text>/</xsl:text>
157 <xslt:choose>
158 <xslt:when test="$metaName = 'hascover'">cover.jpg</xslt:when>
159 <xslt:otherwise>
160 <xslt:value-of disable-output-escaping="yes" select="./metadataList/metadata[@name = $metaName]"/>
161 </xslt:otherwise>
162 </xslt:choose>
163 </xslt:attribute>
164 <!-- copy any other attributes apart from type-->
165 <xsl:for-each select="@*[name() != 'type']">
166 <xslt:attribute name="{name()}">
167 <xsl:value-of select="."/>
168 </xslt:attribute>
169 </xsl:for-each>
170
171 </img>
172 </xslt:if>
173 </xsl:template>
174
175 <!-- make this empty so we don't process the params element again inside the gsf:link type=query-->
176 <xsl:template match="params"></xsl:template>
177
178 <xsl:template match="gsf:link">
179
180 <xslt:variable name="collNameLocal" select="/page/pageResponse/collection/@name"/>
181 <xsl:variable name="opt-title">
182 <xsl:choose>
183 <xsl:when test="@title">
184 <xslt:attribute name="title">
185 <xsl:value-of select="@title"/>
186 </xslt:attribute>
187 </xsl:when>
188 <xsl:when test="@titlekey">
189 <xslt:attribute name="title">
190 <xslt:value-of disable-output-escaping="yes" select="util:getCollectionText($collNameLocal, $site_name, /page/@lang, '{@titlekey}')"/>
191 </xslt:attribute>
192 </xsl:when>
193 </xsl:choose>
194 </xsl:variable>
195
196 <xsl:choose>
197 <xsl:when test="@type='query'">
198 <a>
199 <xsl:if test="@target">
200 <xsl:attribute name='target'>
201 <xsl:value-of select='@target'/>
202 </xsl:attribute>
203 </xsl:if>
204
205 <xslt:attribute name='href'>
206 <xslt:value-of select='$library_name'/>
207 <xsl:text>/collection/</xsl:text>
208 <xslt:value-of select='/page/pageResponse/collection/@name'/>
209 <xsl:text>/search/</xsl:text>
210 <xsl:choose>
211 <xsl:when test="@name">
212 <xsl:value-of select="@name"/>
213 </xsl:when>
214 <xsl:otherwise>
215 <xsl:text>TextQuery</xsl:text>
216 </xsl:otherwise>
217 </xsl:choose>
218 <xsl:for-each select="params">?rt=rd&amp;<xsl:apply-templates/></xsl:for-each>
219
220 </xslt:attribute>
221 <xsl:copy-of select="$opt-title"/>
222 <xsl:apply-templates/>
223 </a>
224 </xsl:when>
225 <xsl:when test="@type='classifier'">
226 <a>
227 <xsl:if test="@target">
228 <xsl:attribute name='target'>
229 <xsl:value-of select='@target'/>
230 </xsl:attribute>
231 </xsl:if>
232
233 <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>
234 </xslt:attribute>
235 <xsl:copy-of select="$opt-title"/>
236 <xsl:apply-templates/>
237 </a>
238 </xsl:when>
239 <xsl:when test="@type='source'">
240 <xslt:variable name="thisAssocfilepath">
241 <xslt:choose>
242 <xslt:when test="/page/pageResponse/document">
243 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']" />
244 </xslt:when>
245 <xslt:otherwise>
246 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='root_assocfilepath']" />
247 </xslt:otherwise>
248 </xslt:choose>
249 </xslt:variable>
250 <a>
251 <xsl:if test="@target">
252 <xsl:attribute name='target'>
253 <xsl:value-of select='@target'/>
254 </xsl:attribute>
255 </xsl:if>
256 <xslt:attribute name='href'>
257 <xslt:value-of
258 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
259 disable-output-escaping="yes" select="$thisAssocfilepath" />/<xslt:value-of
260 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='srclinkFile']" />
261 </xslt:attribute>
262 <xsl:copy-of select="$opt-title"/>
263 <xsl:apply-templates/>
264 </a>
265 </xsl:when>
266 <xsl:when test="@type='web'">
267 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, 'weblink')]"/>
268 <xsl:apply-templates/>
269 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, '/weblink')]"/>
270 </xsl:when>
271 <xsl:when test="@type='page'">
272 <a>
273 <xsl:if test="@target">
274 <xsl:attribute name='target'>
275 <xsl:value-of select='@target'/>
276 </xsl:attribute>
277 </xsl:if>
278
279 <xslt:attribute name='href'>
280 <xslt:value-of select='$library_name'/>
281 <xsl:text>/collection/</xsl:text>
282 <xslt:value-of select='/page/pageResponse/collection/@name'/>
283 <xsl:text>/page/</xsl:text>
284 <xsl:value-of select="@page"/>
285 </xslt:attribute>
286 <xsl:copy-of select="$opt-title"/>
287 <xsl:apply-templates/>
288 </a>
289 </xsl:when>
290 <xsl:when test="@type='equivdoc'">
291 <xsl:call-template name="gsf:equivlinkgs3"/>
292 </xsl:when>
293 <xsl:when test="@type='rss'">
294 <a>
295 <xslt:attribute name='href'>
296 <xslt:value-of select='$library_name'/>
297 <xsl:text>?a=rss&amp;l=en&amp;site=</xsl:text>
298 <xslt:value-of select="$site_name"/>
299 <xsl:text>&amp;c=</xsl:text>
300 <xslt:value-of select='/page/pageResponse/collection/@name'/>
301 </xslt:attribute>
302 <xsl:apply-templates/>
303 </a>
304 </xsl:when>
305 <xsl:otherwise>
306 <!-- a document link -->
307 <xslt:variable name="bookswitch">
308 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
309 </xslt:variable>
310 <a>
311 <xsl:if test="@target">
312 <xsl:attribute name='target'>
313 <xsl:value-of select='@target'/>
314 </xsl:attribute>
315 </xsl:if>
316
317 <xsl:copy-of select="$opt-title"/>
318 <xslt:attribute name="href">
319 <xslt:value-of select='$library_name'/>
320 <xsl:text>/collection/</xsl:text>
321 <xslt:value-of select='/page/pageResponse/collection/@name'/>
322 <xsl:text>/document/</xsl:text>
323 <xsl:choose>
324 <xsl:when test="@OID">
325 <xsl:value-of select="@OID"/>
326 </xsl:when>
327 <xsl:when test="@OIDmetadata">
328 <xsl:variable name="OIDmeta" select="@OIDmetadata"/>
329 <xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$OIDmeta}']"/>
330 </xsl:when>
331 <xsl:otherwise>
332 <xslt:value-of select='@nodeID'/>
333 </xsl:otherwise>
334 </xsl:choose>
335 <xslt:choose>
336 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
337 <xsl:text>?book=on</xsl:text>
338 </xslt:when>
339 <xslt:otherwise>
340 <xslt:if test="$opt-doc-link-args">?<xslt:value-of select="$opt-doc-link-args"/>
341 </xslt:if>
342 </xslt:otherwise>
343 </xslt:choose>
344 </xslt:attribute>
345 <xsl:apply-templates/>
346 </a>
347 </xsl:otherwise>
348 </xsl:choose>
349 </xsl:template>
350
351 <xsl:template match="gsf:OID">
352 <xslt:value-of select="@nodeID"/>
353 </xsl:template>
354 <xsl:template match="gsf:rank">
355 <xslt:value-of select="@rank"/>
356 </xsl:template>
357 <xsl:template match="gsf:icon">
358 <xsl:choose>
359 <xsl:when test="@type='classifier'">
360 <img style="border:0px">
361 <xsl:attribute name="src">
362 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/>
363 </xsl:attribute>
364 </img>
365 </xsl:when>
366 <xsl:when test="@type='web'">
367 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, 'webicon')]"/>
368 </xsl:when>
369 <xsl:when test="@file">
370 <img>
371 <xslt:attribute name='src'>
372 <xsl:choose>
373 <xsl:when test="not(@select) or @select='site'">
374 <xsl:value-of disable-output-escaping="yes" select="concat('interfaces/',$interface_name,'/images/',@file)"/>
375 </xsl:when>
376 <xsl:when test="@select='collection'">
377 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>
378 <xsl:value-of disable-output-escaping="yes" select="concat('/images/',@file)"/>
379 </xsl:when>
380 </xsl:choose>
381 </xslt:attribute>
382 </img>
383 </xsl:when>
384 <xsl:when test="not(@type) or @type='document'">
385 <img style="border:0px">
386 <xslt:attribute name="id">documentBasketBook<xslt:value-of select="/page/pageResponse/collection/@name"/>:<xslt:value-of select="@nodeID"/>
387 </xslt:attribute>
388 <xslt:attribute name="src">
389 <xslt:choose>
390 <xslt:when test="@docType='hierarchy' and @nodeType='root'">
391 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/>
392 </xslt:when>
393 <xslt:otherwise>
394 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/>
395 </xslt:otherwise>
396 </xslt:choose>
397 </xslt:attribute>
398 </img>
399 </xsl:when>
400 </xsl:choose>
401 </xsl:template>
402
403 <!-- calls a template in gslib.xsl in order to avoid xsl vs xslt issue -->
404 <!--<xsl:template match="gsf:equivlinkgs3">
405 <xslt:call-template name="equivDocLinks">
406 <xslt:with-param name="count" select="0"/>
407 </xslt:call-template>
408 </xsl:template>-->
409
410 <!-- 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. -->
411 <xsl:template match="gsf:equivlinkgs3" name="gsf:equivlinkgs3">
412 <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>
413 <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>
414 <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/>
415
416 <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" />
417 <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/>
418 </xsl:template>
419
420 <!--
421In the collection's format statement, could have the following javascript+XSLT in place of
422the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and gslib.xsl).
423<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot;
424</xsl:text>
425<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/>
426<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot;
427</xsl:text>
428<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/>
429<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot;
430</xsl:text>
431<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/>
432<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;
433</xsl:text>
434-->
435
436 <!-- gsf:cgiparam example, as used by the Enhanced PDF tutorial:
437 <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> -->
438 <xsl:template match="gsf:cgi-param">
439 <xslt:value-of disable-output-escaping="yes" select="/page/pageRequest/paramList/param[@name='s1.{@name}']/@value"/>
440 </xsl:template>
441
442 <!-- A GLI user can use a gsf:displayText element in GS3's Format Features to retrieve
443 a string defined in either collectionConfig.xml or else the interface dictionaries.
444 If the requested string occurs in neither, the request string itself will be output. -->
445 <xsl:template match="gsf:displayText">
446 <xslt:variable name="displaytext">
447 <xsl:call-template name="gsf:displayItem"/>
448 </xslt:variable>
449
450 <xslt:choose>
451 <xslt:when test="$displaytext != ''">
452 <xslt:value-of disable-output-escaping="yes" select="$displaytext"/>
453 </xslt:when>
454 <xslt:otherwise>
455 <xslt:variable name="interfacetxt">
456 <xsl:call-template name="gsf:interfaceText"/>
457 </xslt:variable>
458
459 <xslt:choose>
460 <xslt:when test="$interfacetxt != ''">
461 <xslt:value-of disable-output-escaping="yes" select="$interfacetxt"/>
462 </xslt:when>
463 <xslt:otherwise>
464 <xslt:value-of disable-output-escaping="yes" select="'{@name}'"/>
465 </xslt:otherwise>
466 </xslt:choose>
467 </xslt:otherwise>
468 </xslt:choose>
469 </xsl:template>
470
471 <!-- With gsf:displayItem, a user can request a displayItem from collectionConfig.xml -->
472 <xsl:template match="gsf:displayItem" name="gsf:displayItem">
473 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/displayItemList/displayItem[@name='{@name}']"/>
474 </xsl:template>
475
476 <!-- With gsf:interfaceText, a user can request a string from the interface dictionaries in the current lang -->
477 <xsl:template match="gsf:interfaceText" name="gsf:interfaceText">
478 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, /page/@lang, '{@name}')"/>
479 </xsl:template>
480 <!-- With gsf:collectionText, a user can request a string from the collection's dictionary in the current lang -->
481 <xsl:template match="gsf:collectionText" name="gsf:collectionText">
482 <xslt:variable name="collName" select="/page/pageResponse/collection/@name"/>
483 <xslt:copy-of select="util:getCollectionText($collName, $site_name, /page/@lang, '{@name}', '{@args}')/node()"/>
484 </xsl:template>
485
486 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
487 <xsl:template match="gsf:metadata">
488 <xsl:if test="not(@hidden = 'true')">
489 <!-- set hidden=true on a gsf:metadata so that it gets retrieved from the server but not displayed -->
490 <xsl:variable name="meta_test"><xsl:call-template name="getMetadataTest"/></xsl:variable>
491 <xsl:variable name="separator">
492 <xsl:choose>
493 <xsl:when test="@separator">
494 <xsl:choose>
495 <xsl:when test="@separator = ' '">
496 <!-- http://stackoverflow.com/questions/1461649/how-to-insert-nbsp-in-xslt -->
497 <xsl:text>&#160;</xsl:text>
498 <!--<xsl:text> </xsl:text> only works in GLI's Format panel-->
499 <!--<xsl:text disable-output-escaping="yes"><![CDATA[&nbsp;]]></xsl:text>-->
500 </xsl:when>
501 <xsl:otherwise>
502 <xsl:value-of disable-output-escaping='yes' select="@separator"/>
503 </xsl:otherwise>
504 </xsl:choose>
505 </xsl:when>
506 <xsl:when test="separator">
507 <xsl:copy-of select="separator/node()"/>
508 </xsl:when>
509 <xsl:otherwise>
510 <xsl:text>, </xsl:text>
511 </xsl:otherwise>
512 </xsl:choose>
513 </xsl:variable>
514 <xsl:variable name="prefix">
515 <xsl:choose>
516 <xsl:when test="@prefix">
517 <xsl:value-of disable-output-escaping='yes' select="@prefix"/>
518 </xsl:when>
519 <xsl:when test="prefix">
520 <xsl:copy-of select="prefix/node()"/>
521 </xsl:when>
522 </xsl:choose>
523 </xsl:variable>
524 <xsl:variable name="suffix">
525 <xsl:choose>
526 <xsl:when test="@suffix">
527 <xsl:value-of disable-output-escaping='yes' select="@suffix"/>
528 </xsl:when>
529 <xsl:when test="suffix">
530 <xsl:copy-of select="suffix/node()"/>
531 </xsl:when>
532 </xsl:choose>
533 </xsl:variable>
534 <xsl:variable name="postest">
535 <xsl:choose>
536 <xsl:when test="@pos = 'first'">position()=1</xsl:when>
537 <xsl:when test="@pos = 'last'">position() = last()</xsl:when>
538 <xsl:when test="@pos = 'classifiedBy'">position() = number(../../@mdoffset)+1</xsl:when>
539 <xsl:when test="@pos">position() = <xsl:value-of select="@pos"/>
540 </xsl:when>
541 <xsl:otherwise>true()</xsl:otherwise>
542 </xsl:choose>
543 </xsl:variable>
544 <xsl:variable name="multiple">
545 <xsl:choose>
546 <xsl:when test="@pos">false()</xsl:when>
547 <xsl:otherwise>true()</xsl:otherwise>
548 </xsl:choose>
549 </xsl:variable>
550 <xslt:for-each>
551 <xsl:attribute name="select">
552 (<xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>.//metadataList)[last()]/metadata[<xsl:value-of select="$meta_test"/><xsl:if test="@lang">
553 <xsl:text> and @lang=</xsl:text>
554 <xsl:value-of select="@lang"/>
555 </xsl:if>
556 <xsl:text>]</xsl:text>
557 </xsl:attribute>
558 <xslt:if test="{$postest}">
559 <xslt:if test="{$multiple} and position()>1"><xsl:copy-of select="$separator"/>
560 </xslt:if>
561 <xsl:copy-of select="$prefix"/>
562 <xsl:choose>
563 <xsl:when test="@format">
564 <xslt:value-of disable-output-escaping='yes' select="util:{@format}(., /page/@lang )"/>
565 </xsl:when>
566 <xsl:otherwise>
567 <xslt:value-of disable-output-escaping='yes' select="."/>
568 </xsl:otherwise>
569 </xsl:choose>
570 </xslt:if>
571 <xsl:copy-of select="$suffix"/>
572 </xslt:for-each>
573 </xsl:if>
574 </xsl:template>
575
576
577 <xsl:template match="gsf:foreach-metadata">
578 <xsl:variable name="meta_name"><xsl:call-template name="getMetadataName"/></xsl:variable>
579 <xslt:for-each>
580 <xsl:attribute name="select">
581 (<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>
582 </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>
583 <xsl:apply-templates/>
584 </xslt:for-each>
585 </xsl:template>
586
587 <xsl:template match="gsf:meta-value">
588 <xslt:value-of select="."/>
589 </xsl:template>
590
591 <xsl:template name="getMetadataName">
592 <xsl:if test='@select'>
593 <xsl:value-of select='@select'/>
594 <xsl:text>_</xsl:text>
595 </xsl:if>
596 <xsl:call-template name="stripEx"><xsl:with-param name="meta-name" select="@name"/></xsl:call-template>
597 </xsl:template>
598
599 <!-- 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 -->
600 <xsl:template name="stripEx">
601 <xsl:param name="meta-name"/>
602 <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>
603 </xsl:template>
604
605 <!-- if we have metadata name="dc.Date,Date" will make a test like (@name = 'dc.Date' or @name = 'Date') -->
606 <xsl:template name="getMetadataTest">
607 <xsl:variable name="selectattr"><xsl:value-of select='@select'/></xsl:variable>
608 (<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>)
609 </xsl:template>
610
611 <xsl:template match="gsf:text">
612 <xslt:call-template name="documentNodeText"/>
613 </xsl:template>
614
615 <xsl:template match="gsf:if-metadata-exists">
616 <xsl:variable name="meta-path">
617 <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>
618 </xsl:variable>
619 <xslt:choose>
620 <xslt:when test="{$meta-path}">
621 <xsl:apply-templates select="gsf:if/node()"/>
622 </xslt:when>
623 <xsl:if test="gsf:else">
624 <xslt:otherwise>
625 <xsl:apply-templates select="gsf:else/node()"/>
626 </xslt:otherwise>
627 </xsl:if>
628 </xslt:choose>
629 </xsl:template>
630
631 <xsl:template match="gsf:choose-metadata">
632 <xslt:choose>
633 <xsl:for-each select="gsf:metadata">
634 <xslt:when>
635 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:attribute>
636 <xsl:apply-templates select="."/>
637 </xslt:when>
638 </xsl:for-each>
639 <xsl:if test="gsf:default">
640 <xslt:otherwise>
641 <xsl:apply-templates select="gsf:default"/>
642 </xslt:otherwise>
643 </xsl:if>
644 </xslt:choose>
645 </xsl:template>
646
647 <xsl:template match="gsf:switch">
648 <xsl:variable name="meta-name">
649 <xsl:for-each select="gsf:metadata">
650 <xsl:call-template name="getMetadataName"/>
651 </xsl:for-each>
652 </xsl:variable>
653 <xslt:variable name="meta">
654 <xsl:choose>
655 <xsl:when test="@preprocess">
656 <xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'], /page/@lang )"/>
657 </xsl:when>
658 <xsl:otherwise>
659 <xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/>
660 </xsl:otherwise>
661 </xsl:choose>
662 </xslt:variable>
663 <xslt:choose>
664 <xsl:for-each select="gsf:when">
665 <xslt:when test="util:{@test}($meta, '{@test-value}')">
666 <xsl:apply-templates/>
667 </xslt:when>
668 </xsl:for-each>
669 <xsl:if test="gsf:otherwise">
670 <xslt:otherwise>
671 <xsl:apply-templates select="gsf:otherwise/node()"/>
672 </xslt:otherwise>
673 </xsl:if>
674 </xslt:choose>
675 </xsl:template>
676
677 <!--
678 <gsf:headMetaTags> exists for controlling the <meta name="x" content="y"> elements that appear in the HTML <head></head>
679 XPATH is used to select this item (in header.xsl). It does not need an explicit definition here in this file
680 -->
681 <!-- this template is used to avoid the user having to type
682 <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 -->
683 <xsl:template match="gsf:html">
684 <xslt:text disable-output-escaping="yes"><xsl:value-of select="."/></xslt:text>
685 </xsl:template>
686 <!-- use this if you want a space after an element in the output.
687 e.g. <strong>Title:><gsf:space/></strong -->
688 <xsl:template match="gsf:space">&#160;</xsl:template>
689 <xsl:template match="*">
690 <xsl:copy>
691 <xsl:copy-of select="@*"/>
692 <xsl:apply-templates/>
693 </xsl:copy>
694 </xsl:template>
695
696</xsl:stylesheet>
697
698
Note: See TracBrowser for help on using the repository browser.