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

Last change on this file since 29223 was 29223, checked in by kjdon, 10 years ago

get assocfilepath from top level document metadata, as individual sections don't store it

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