source: main/trunk/greenstone3/web/interfaces/default_old/transform/config_format.xsl@ 32839

Last change on this file since 32839 was 29861, checked in by Georgiy Litvinov, 9 years ago

renamed interfaces

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