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

Last change on this file since 30699 was 30699, checked in by kjdon, 8 years ago

reversing one of my previous commits. The full path here is important. assocfilepath is only found at the document metadataList, not in a subsections metadataList. So need to get from document's list, not local sections list

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