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

Last change on this file since 30049 was 29936, checked in by davidb, 9 years ago

Introduction of new template to help with including empty 'div' elements in the GS3 XSLT processing pipeline

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