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

Last change on this file since 26317 was 26317, checked in by kjdon, 12 years ago

more modes to get niupepa collection working

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