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

Last change on this file since 32503 was 32503, checked in by kjdon, 6 years ago

2 things. if @highlight attribute set on gsf:metadata, then output the value using displayMarkedUpTextAndAnnotations. only works for document display templates. 2. can put @force=true to gsf:text - this will output 'this document has no text' if that is the value, instead of hiding it.

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