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

Last change on this file since 30478 was 30478, checked in by davidb, 8 years ago

Changes in the XSL and JS code to support the new approach taken to client-side XSLT (using Saxon-CE JS library in the browser). Also the reintroduction of the DirectEdit (Seaweed) template. Not on by default but a simple matter to call the re-instated template for projects that would like to make use of it, such as the digital music stand DL collection. Some white-space changes also occured. This was not deliberate, but would have been quite fiddly to tease out from other changes in the file, so consequently left in.

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