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

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

added in gsf:html template. this template is used to avoid the user having to type <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

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