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

Last change on this file since 26347 was 26347, checked in by sjm84, 12 years ago

We want to get the children of the fragment elements produced from the getCollectionText call

File size: 17.4 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:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
8 extension-element-prefixes="java">
9 <xsl:param name="interface_name"/>
10 <xsl:param name="library_name"/>
11 <xsl:param name="site_name"/>
12 <xsl:param name="collName"/>
13
14 <xsl:output method="xml"/>
15 <xsl:namespace-alias stylesheet-prefix="xslt" result-prefix="xsl"/>
16
17 <xsl:template match="format">
18 <format>
19 <xsl:apply-templates/>
20 </format>
21 </xsl:template>
22
23 <xsl:template match="gsf:template">
24 <xslt:template>
25 <xsl:copy-of select="@*"/>
26 <xsl:attribute name="priority">2</xsl:attribute>
27 <xsl:if test=".//gsf:link">
28 <xslt:param name="serviceName"/>
29 <xslt:param name="collName"/>
30 </xsl:if>
31 <xsl:apply-templates/>
32 </xslt:template>
33 </xsl:template>
34
35 <xsl:template match="gsf:variable">
36 <xslt:variable>
37 <xsl:copy-of select="@*"/>
38 <xsl:apply-templates/>
39 </xslt:variable>
40 <script type="text/javascript">
41 gs.variables.<xsl:value-of select="@name"/><xslt:text disable-output-escaping="yes"> = "</xslt:text><xsl:apply-templates/><xslt:text disable-output-escaping="yes">";</xslt:text>
42 </script>
43 </xsl:template>
44
45 <xsl:template match="gsf:defaultClassifierNode">
46 <xslt:call-template name="defaultClassifierNode"/>
47 </xsl:template>
48
49 <xsl:template match="gsf:image">
50 <xslt:variable name="metaName">
51 <xsl:choose>
52 <xsl:when test="@type = 'thumb'">Thumb</xsl:when>
53 <xsl:when test="@type = 'screen'">Screen</xsl:when>
54 <xsl:when test="@type = 'source'">SourceFile</xsl:when>
55 </xsl:choose>
56 </xslt:variable>
57 <xslt:if test="(.//metadataList)[last()]/metadata[@name = $metaName]">
58 <img>
59 <xslt:attribute name='src'>
60 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
61 <xsl:text>/index/assoc/</xsl:text>
62 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name = 'assocfilepath']"/>
63 <xsl:text>/</xsl:text>
64 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = $metaName]"/>
65 </xslt:attribute>
66 </img>
67 </xslt:if>
68 </xsl:template>
69
70 <xsl:template match="gsf:link">
71 <xslt:variable name="collName" select="/page/pageResponse/collection/@name"/>
72 <xsl:variable name="opt-title">
73 <xsl:choose>
74 <xsl:when test="@title"><xslt:attribute name="title"><xsl:value-of select="@title"/></xslt:attribute></xsl:when>
75 <xsl:when test="@titlekey"><xslt:attribute name="title"><xslt:value-of disable-output-escaping="yes" select="util:getCollectionText($collName, $site_name, /page/@lang, '{@titlekey}')"/></xslt:attribute></xsl:when>
76 </xsl:choose>
77 </xsl:variable>
78 <xsl:choose>
79 <xsl:when test="@type='query'">
80 <a>
81 <xslt:attribute name='href'>
82 <xslt:value-of select='$library_name'/>
83 <xsl:text>/collection/</xsl:text>
84 <xslt:value-of select='/page/pageResponse/collection/@name'/>
85 <xsl:text>/search/</xsl:text>
86 <xsl:choose>
87 <xsl:when test="@name">
88 <xsl:value-of select="@name"/>
89 </xsl:when>
90 <xsl:otherwise>
91 <xsl:text>TextQuery</xsl:text>
92 </xsl:otherwise>
93 </xsl:choose>
94 </xslt:attribute>
95 <xsl:copy-of select="$opt-title"/>
96 <xsl:apply-templates/>
97 </a>
98 </xsl:when>
99 <xsl:when test="@type='classifier'">
100 <a>
101 <xslt:attribute name='href'>
102 <xslt:value-of select='$library_name'/>
103 <xsl:text>/collection/</xsl:text>
104 <xslt:value-of select='/page/pageResponse/collection/@name'/>
105 <xsl:text>/browse/</xsl:text>
106 <xsl:choose>
107 <xsl:when test="@nodeID">
108 <xsl:value-of select="@nodeID"/>
109 </xsl:when>
110 <xsl:otherwise>
111 <xslt:value-of select='util:replace(@nodeID, ".", "/")'/>
112 </xsl:otherwise>
113 </xsl:choose>
114 </xslt:attribute>
115 <xsl:copy-of select="$opt-title"/>
116 <xsl:apply-templates/>
117 </a>
118 </xsl:when>
119 <xsl:when test="@type='source'">
120 <a><xslt:attribute name='href'><xslt:value-of
121 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
122 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='assocfilepath']" />/<xslt:value-of
123 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='srclinkFile']" /></xslt:attribute>
124 <xsl:copy-of select="$opt-title"/>
125 <xsl:apply-templates/>
126 </a>
127 </xsl:when>
128 <xsl:when test="@type='web'">
129 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, 'weblink')]"/>
130 <xsl:apply-templates/>
131 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, '/weblink')]"/>
132 </xsl:when>
133 <xsl:when test="@type='page'">
134 <a>
135 <xslt:attribute name='href'>
136 <xslt:value-of select='$library_name'/>
137 <xsl:text>/collection/</xsl:text>
138 <xslt:value-of select='/page/pageResponse/collection/@name'/>
139 <xsl:text>/page/</xsl:text>
140 <xsl:value-of select="@page"/>
141 </xslt:attribute>
142 <xsl:copy-of select="$opt-title"/>
143 <xsl:apply-templates/>
144 </a>
145 </xsl:when>
146 <xsl:when test="@type='equivdoc'">
147 <xsl:call-template name="gsf:equivlinkgs3"/>
148 </xsl:when>
149 <xsl:otherwise> <!-- a document link -->
150 <xslt:variable name="bookswitch">
151 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
152 </xslt:variable>
153 <a>
154 <xsl:copy-of select="$opt-title"/>
155 <xslt:attribute name="href">
156 <xslt:value-of select='$library_name'/>
157 <xsl:text>/collection/</xsl:text>
158 <xslt:value-of select='/page/pageResponse/collection/@name'/>
159 <xsl:text>/document/</xsl:text>
160 <xsl:choose><xsl:when test="@OID"><xsl:value-of select="@OID"/></xsl:when><xsl:when test="@OIDmetadata"><xsl:variable name="OIDmeta" select="@OIDmetadata"/><xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$OIDmeta}']"/></xsl:when><xsl:otherwise>
161 <xslt:value-of select='@nodeID'/></xsl:otherwise></xsl:choose>
162 <xslt:choose>
163 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
164 <xsl:text>?book=on</xsl:text>
165 </xslt:when>
166 <xslt:otherwise>
167 <xslt:if test="$opt-doc-link-args">?<xslt:value-of select="$opt-doc-link-args"/></xslt:if>
168 </xslt:otherwise>
169 </xslt:choose>
170 </xslt:attribute>
171 <xsl:apply-templates/>
172 </a>
173 </xsl:otherwise>
174 </xsl:choose>
175 </xsl:template>
176
177 <xsl:template match="gsf:icon">
178 <xsl:choose>
179 <xsl:when test="@type='classifier'">
180 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
181 </xsl:when>
182 <xsl:when test="@type='web'">
183 <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[contains(@name, 'webicon')]"/>
184 </xsl:when>
185 <xsl:when test="@file">
186 <img>
187 <xslt:attribute name='src'>
188 <xsl:choose>
189 <xsl:when test="not(@select) or @select='site'">
190 <xsl:value-of disable-output-escaping="yes" select="concat('interfaces/',$interface_name,'/images/',@file)"/>
191 </xsl:when>
192 <xsl:when test="@select='collection'">
193 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>
194 <xsl:value-of disable-output-escaping="yes" select="concat('/images/',@file)"/>
195 </xsl:when>
196 </xsl:choose>
197 </xslt:attribute>
198 </img>
199 </xsl:when>
200 <xsl:when test="not(@type) or @type='document'">
201 <img style="border:0px"><xslt:attribute name="id">documentBasketBook<xslt:value-of select="/page/pageResponse/collection/@name"/>:<xslt:value-of select="@nodeID"/></xslt:attribute><xslt:attribute name="src">
202 <xslt:choose>
203 <xslt:when test="@docType='hierarchy' and @nodeType='root'">
204 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'book_image')"/>
205 </xslt:when>
206 <xslt:otherwise>
207 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/>
208 </xslt:otherwise>
209 </xslt:choose>
210 </xslt:attribute></img>
211 </xsl:when>
212 </xsl:choose>
213 </xsl:template>
214
215 <!-- calls a template in gslib.xsl in order to avoid xsl vs xslt issue -->
216 <!--<xsl:template match="gsf:equivlinkgs3">
217 <xslt:call-template name="equivDocLinks">
218 <xslt:with-param name="count" select="0"/>
219 </xslt:call-template>
220 </xsl:template>-->
221
222 <!-- 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. -->
223 <xsl:template match="gsf:equivlinkgs3" name="gsf:equivlinkgs3">
224 <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>
225 <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>
226 <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/>
227
228 <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" />
229 <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/>
230 </xsl:template>
231
232<!--
233In the collection's format statement, could have the following javascript+XSLT in place of
234the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and gslib.xsl).
235<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot;
236</xsl:text>
237<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/>
238<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot;
239</xsl:text>
240<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/>
241<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot;
242</xsl:text>
243<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/>
244<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;
245</xsl:text>
246-->
247
248 <!-- gsf:cgiparam example, as used by the Enhanced PDF tutorial:
249 <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> -->
250 <xsl:template match="gsf:cgi-param">
251 <xslt:value-of disable-output-escaping="yes" select="/page/pageRequest/paramList/param[@name='s1.{@name}']/@value"/>
252 </xsl:template>
253
254 <!-- A GLI user can use a gsf:displayText element in GS3's Format Features to retrieve
255 a string defined in either collectionConfig.xml or else the interface dictionaries.
256 If the requested string occurs in neither, the request string itself will be output. -->
257 <xsl:template match="gsf:displayText">
258 <xslt:variable name="displaytext">
259 <xsl:call-template name="gsf:displayItem"/>
260 </xslt:variable>
261
262 <xslt:choose>
263 <xslt:when test="$displaytext != ''">
264 <xslt:value-of disable-output-escaping="yes" select="$displaytext"/>
265 </xslt:when>
266 <xslt:otherwise>
267 <xslt:variable name="interfacetxt">
268 <xsl:call-template name="gsf:interfaceText"/>
269 </xslt:variable>
270
271 <xslt:choose>
272 <xslt:when test="$interfacetxt != ''">
273 <xslt:value-of disable-output-escaping="yes" select="$interfacetxt"/>
274 </xslt:when>
275 <xslt:otherwise>
276 <xslt:value-of disable-output-escaping="yes" select="'{@name}'"/>
277 </xslt:otherwise>
278 </xslt:choose>
279 </xslt:otherwise>
280 </xslt:choose>
281 </xsl:template>
282
283 <!-- With gsf:displayItem, a user can request a displayItem from collectionConfig.xml -->
284 <xsl:template match="gsf:displayItem" name="gsf:displayItem">
285 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/displayItem[@name='{@name}']"/>
286 </xsl:template>
287
288 <!-- With gsf:interfaceText, a user can request a string from the interface dictionaries in the current lang -->
289 <xsl:template match="gsf:interfaceText" name="gsf:interfaceText">
290 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, /page/@lang, '{@name}')"/>
291 </xsl:template>
292 <!-- With gsf:collectionText, a user can request a string from the collection's dictionary in the current lang -->
293 <xsl:template match="gsf:collectionText" name="gsf:collectionText">
294 <xslt:variable name="collName" select="/page/pageResponse/collection/@name"/>
295 <xslt:value-of select="util:getCollectionText($collName, $site_name, /page/@lang, '{@name}', '{@args}')/*"/>
296 </xsl:template>
297
298 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
299 <xsl:template match="gsf:metadata">
300 <xsl:if test="not(@hidden = 'true')">
301 <!-- set hidden=true on a gsf:metadata so that it gets retrieved from the server but not displayed -->
302 <xsl:variable name="meta_name"><xsl:call-template name="getMetadataName"/></xsl:variable>
303 <xsl:variable name="separator">
304 <xsl:choose>
305 <xsl:when test="@separator"><xsl:value-of disable-output-escaping='yes' select="@separator"/></xsl:when>
306 <xsl:when test="separator"><xsl:copy-of select="separator/node()"/></xsl:when>
307 <xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise>
308 </xsl:choose>
309 </xsl:variable>
310 <xsl:variable name="prefix">
311 <xsl:choose>
312 <xsl:when test="@prefix"><xsl:value-of disable-output-escaping='yes' select="@prefix"/></xsl:when>
313 <xsl:when test="prefix"><xsl:copy-of select="prefix/node()"/></xsl:when>
314 </xsl:choose>
315 </xsl:variable>
316 <xsl:variable name="suffix">
317 <xsl:choose>
318 <xsl:when test="@suffix"><xsl:value-of disable-output-escaping='yes' select="@suffix"/></xsl:when>
319 <xsl:when test="suffix"><xsl:copy-of select="suffix/node()"/></xsl:when>
320 </xsl:choose>
321 </xsl:variable>
322 <xsl:variable name="postest">
323 <xsl:choose>
324 <xsl:when test="@pos = 'first'">position()=1</xsl:when>
325 <xsl:when test="@pos = 'last'">position() = last()</xsl:when>
326 <xsl:when test="@pos">position() = <xsl:value-of select="@pos"/></xsl:when>
327 <xsl:otherwise>true()</xsl:otherwise>
328 </xsl:choose>
329 </xsl:variable>
330 <xsl:variable name="multiple">
331 <xsl:choose>
332 <xsl:when test="@pos">false()</xsl:when>
333 <xsl:otherwise>true()</xsl:otherwise>
334 </xsl:choose>
335 </xsl:variable>
336 <xslt:for-each>
337 <xsl:attribute name="select">
338 <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>
339 </xsl:attribute>
340 <xslt:if test="{$postest}">
341 <xslt:if test="{$multiple} and position()>1"><xsl:copy-of select="$separator"/></xslt:if>
342 <xsl:copy-of select="$prefix"/>
343 <xsl:choose>
344 <xsl:when test="@format">
345 <xslt:value-of disable-output-escaping='yes' select="util:{@format}(., /page/@lang )"/>
346 </xsl:when>
347 <xsl:otherwise>
348 <xslt:value-of disable-output-escaping='yes' select="."/>
349 </xsl:otherwise>
350 </xsl:choose>
351 </xslt:if>
352 <xsl:copy-of select="$suffix"/>
353 </xslt:for-each>
354 </xsl:if>
355 </xsl:template>
356
357 <xsl:template name="getMetadataName">
358 <xsl:if test='@select'>
359 <xsl:value-of select='@select'/>
360 <xsl:text>_</xsl:text>
361 </xsl:if>
362 <xsl:value-of select="@name"/>
363 </xsl:template>
364
365 <xsl:template match="gsf:text">
366 <xslt:call-template name="documentNodeText"/>
367 </xsl:template>
368
369 <xsl:template match="gsf:choose-metadata">
370 <xslt:choose>
371 <xsl:for-each select="gsf:metadata">
372 <xslt:when>
373 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:attribute>
374 <xsl:apply-templates select="."/>
375 </xslt:when>
376 </xsl:for-each>
377 <xsl:if test="gsf:default">
378 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
379 </xsl:if>
380 </xslt:choose>
381 </xsl:template>
382
383 <xsl:template match="gsf:switch">
384 <xsl:variable name="meta-name"><xsl:for-each select="gsf:metadata"><xsl:call-template name="getMetadataName"/></xsl:for-each></xsl:variable>
385 <xslt:variable name="meta"><xsl:choose><xsl:when test="@preprocess"><xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'], /page/@lang )"/></xsl:when><xsl:otherwise><xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/></xsl:otherwise></xsl:choose></xslt:variable>
386 <xslt:choose>
387 <xsl:for-each select="gsf:when">
388 <xslt:when test="util:{@test}($meta, '{@test-value}')">
389 <xsl:apply-templates/>
390 </xslt:when>
391 </xsl:for-each>
392 <xsl:if test="gsf:otherwise">
393 <xslt:otherwise>
394 <xsl:apply-templates select="gsf:otherwise/node()"/>
395 </xslt:otherwise>
396 </xsl:if>
397 </xslt:choose>
398 </xsl:template>
399
400 <xsl:template match="*">
401 <xsl:copy>
402 <xsl:copy-of select="@*"/>
403 <xsl:apply-templates/>
404 </xsl:copy>
405 </xsl:template>
406
407</xsl:stylesheet>
408
409
Note: See TracBrowser for help on using the repository browser.