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

Last change on this file since 29245 was 29245, checked in by ak19, 10 years ago

Dr Bainbridge fixed a bug that is apparent when doing the final step of the basic Scanned Image tutorial. The reference to the parent's metadata to obtain the parent's volume number and title failed. The metadata was being requested and was returned in the response from the GS3 server, but the returned metadata has parent_ prefixed to the metanames Volume and Title but the config_format.xsl wasn't prefixing the parent_ when trying to access the metadata from the xml. Dr Bainbridge's fixes this.

File size: 23.1 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:value-of disable-output-escaping='yes' select="@separator"/>
458 </xsl:when>
459 <xsl:when test="separator">
460 <xsl:copy-of select="separator/node()"/>
461 </xsl:when>
462 <xsl:otherwise>
463 <xsl:text>, </xsl:text>
464 </xsl:otherwise>
465 </xsl:choose>
466 </xsl:variable>
467 <xsl:variable name="prefix">
468 <xsl:choose>
469 <xsl:when test="@prefix">
470 <xsl:value-of disable-output-escaping='yes' select="@prefix"/>
471 </xsl:when>
472 <xsl:when test="prefix">
473 <xsl:copy-of select="prefix/node()"/>
474 </xsl:when>
475 </xsl:choose>
476 </xsl:variable>
477 <xsl:variable name="suffix">
478 <xsl:choose>
479 <xsl:when test="@suffix">
480 <xsl:value-of disable-output-escaping='yes' select="@suffix"/>
481 </xsl:when>
482 <xsl:when test="suffix">
483 <xsl:copy-of select="suffix/node()"/>
484 </xsl:when>
485 </xsl:choose>
486 </xsl:variable>
487 <xsl:variable name="postest">
488 <xsl:choose>
489 <xsl:when test="@pos = 'first'">position()=1</xsl:when>
490 <xsl:when test="@pos = 'last'">position() = last()</xsl:when>
491 <xsl:when test="@pos = 'classifiedBy'">position() = number(../../@mdoffset)+1</xsl:when>
492 <xsl:when test="@pos">position() = <xsl:value-of select="@pos"/>
493 </xsl:when>
494 <xsl:otherwise>true()</xsl:otherwise>
495 </xsl:choose>
496 </xsl:variable>
497 <xsl:variable name="multiple">
498 <xsl:choose>
499 <xsl:when test="@pos">false()</xsl:when>
500 <xsl:otherwise>true()</xsl:otherwise>
501 </xsl:choose>
502 </xsl:variable>
503 <xslt:for-each>
504 <xsl:attribute name="select">
505 (<xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>.//metadataList)[last()]/metadata[<xsl:value-of select="$meta_test"/><xsl:if test="@lang">
506 <xsl:text> and @lang=</xsl:text>
507 <xsl:value-of select="@lang"/>
508 </xsl:if>
509 <xsl:text>]</xsl:text>
510 </xsl:attribute>
511 <xslt:if test="{$postest}">
512 <xslt:if test="{$multiple} and position()>1"><xsl:copy-of select="$separator"/>
513 </xslt:if>
514 <xsl:copy-of select="$prefix"/>
515 <xsl:choose>
516 <xsl:when test="@format">
517 <xslt:value-of disable-output-escaping='yes' select="util:{@format}(., /page/@lang )"/>
518 </xsl:when>
519 <xsl:otherwise>
520 <xslt:value-of disable-output-escaping='yes' select="."/>
521 </xsl:otherwise>
522 </xsl:choose>
523 </xslt:if>
524 <xsl:copy-of select="$suffix"/>
525 </xslt:for-each>
526 </xsl:if>
527 </xsl:template>
528
529
530 <xsl:template match="gsf:foreach-metadata">
531 <xsl:variable name="meta_name"><xsl:call-template name="getMetadataName"/></xsl:variable>
532 <xslt:for-each>
533 <xsl:attribute name="select">
534 (<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>
535 </xsl:attribute><xsl:if test='@separator'><xslt:if test='position()>1'><xsl:value-of select='@separator'/></xslt:if></xsl:if>
536 <xsl:apply-templates/>
537 </xslt:for-each>
538 </xsl:template>
539
540 <xsl:template match="gsf:meta-value">
541 <xslt:value-of select="."/>
542 </xsl:template>
543
544 <xsl:template name="getMetadataName">
545 <xsl:if test='@select'>
546 <xsl:value-of select='@select'/>
547 <xsl:text>_</xsl:text>
548 </xsl:if>
549 <xsl:value-of select="@name"/>
550 </xsl:template>
551
552 <!-- if we have metadata name="dc.Date,Date" will make a test like (@name = 'dc.Date' or @name = 'Date') -->
553 <xsl:template name="getMetadataTest">
554 <xsl:variable name="selectattr"><xsl:value-of select='@select'/></xsl:variable>
555 (<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:value-of select="."/>'</xsl:for-each>)
556 </xsl:template>
557
558 <xsl:template match="gsf:text">
559 <xslt:call-template name="documentNodeText"/>
560 </xsl:template>
561
562 <xsl:template match="gsf:if-metadata-exists">
563 <xsl:variable name="meta-path">
564 <xsl:for-each select="gsf:metadata">(.//metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:for-each>
565 </xsl:variable>
566 <xslt:choose>
567 <xslt:when test="{$meta-path}">
568 <xsl:apply-templates select="gsf:if/node()"/>
569 </xslt:when>
570 <xsl:if test="gsf:else">
571 <xslt:otherwise>
572 <xsl:apply-templates select="gsf:else/node()"/>
573 </xslt:otherwise>
574 </xsl:if>
575 </xslt:choose>
576 </xsl:template>
577
578 <xsl:template match="gsf:choose-metadata">
579 <xslt:choose>
580 <xsl:for-each select="gsf:metadata">
581 <xslt:when>
582 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:attribute>
583 <xsl:apply-templates select="."/>
584 </xslt:when>
585 </xsl:for-each>
586 <xsl:if test="gsf:default">
587 <xslt:otherwise>
588 <xsl:apply-templates select="gsf:default"/>
589 </xslt:otherwise>
590 </xsl:if>
591 </xslt:choose>
592 </xsl:template>
593
594 <xsl:template match="gsf:switch">
595 <xsl:variable name="meta-name">
596 <xsl:for-each select="gsf:metadata">
597 <xsl:call-template name="getMetadataName"/>
598 </xsl:for-each>
599 </xsl:variable>
600 <xslt:variable name="meta">
601 <xsl:choose>
602 <xsl:when test="@preprocess">
603 <xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'], /page/@lang )"/>
604 </xsl:when>
605 <xsl:otherwise>
606 <xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/>
607 </xsl:otherwise>
608 </xsl:choose>
609 </xslt:variable>
610 <xslt:choose>
611 <xsl:for-each select="gsf:when">
612 <xslt:when test="util:{@test}($meta, '{@test-value}')">
613 <xsl:apply-templates/>
614 </xslt:when>
615 </xsl:for-each>
616 <xsl:if test="gsf:otherwise">
617 <xslt:otherwise>
618 <xsl:apply-templates select="gsf:otherwise/node()"/>
619 </xslt:otherwise>
620 </xsl:if>
621 </xslt:choose>
622 </xsl:template>
623
624 <!--
625 <gsf:headMetaTags> exists for controlling the <meta name="x" content="y"> elements that appear in the HTML <head></head>
626 XPATH is used to select this item (in header.xsl). It does not need an explicit definition here in this file
627 -->
628
629 <xsl:template match="*">
630 <xsl:copy>
631 <xsl:copy-of select="@*"/>
632 <xsl:apply-templates/>
633 </xsl:copy>
634 </xsl:template>
635
636</xsl:stylesheet>
637
638
Note: See TracBrowser for help on using the repository browser.