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

Last change on this file since 31537 was 31537, checked in by ak19, 7 years ago

First commit for getting user comments working for GS3. It all works, but there's debugging statements still and haven't cleaned up commented out code. After that, would like to make POST rather than GET AJAX calls, so more refactoring required. 1. config_format.xsl is just minor spelling corrections. 2. header.xsl has a new function generateLogoutURL. 3. document.xsl imports and calls new usercomments.xsl to set up the user comments area. 4. New usercomments.js is imported by new usercomments.xsl, and sets up the interaction of the usercomments area. 5. javascript-global-functions.js now contains setMetadataArray and getMetadataArray functions to parallel what GS2 used in gsajaxapi.js, but for GS3 need to go through GS2Construct.processModifyMetadata() service in java code. 5. GS2Construct.java does different checking for users adding user comments versus users doing document editing. For the latter, the user needs to have editing permissions for the document. But any user is allowed to add comments on any accessible document. But ModifyMetadata should not allow any other metadata to be modified other than meta fields. 6. New language strings for usercomment area and GS2Construct errors in the 2 changed properties files.

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