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

Last change on this file since 26031 was 26031, checked in by ak19, 12 years ago
  1. Trying to reintroduce use of mdoffset when pos=offset, for when using associated files. 2. The alternative for expanding gsf:equivlinkgs3 is shorter and less involved. As this worked equally well when trying out the DSpace tutorial with GS3, the simpler equivlinkgs3 template is now active and the more complicated one is commented out. Once I try the associated files tutorial with GS3, this change may become more definite.
File size: 13.3 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
12 <xsl:output method="xml"/>
13 <xsl:namespace-alias stylesheet-prefix="xslt" result-prefix="xsl"/>
14
15 <xsl:template match="format">
16 <format>
17 <xsl:apply-templates/>
18 </format>
19 </xsl:template>
20
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>
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>
42
43 <xsl:template match="gsf:defaultClassifierNode">
44 <xslt:call-template name="defaultClassifierNode"/>
45 </xsl:template>
46
47 <xsl:template match="gsf:image">
48 <xslt:variable name="metaName">
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>
54 </xslt:variable>
55 <xslt:if test="(.//metadataList)[last()]/metadata[@name = $metaName]">
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>
62 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = $metaName]"/>
63 </xslt:attribute>
64 </img>
65 </xslt:if>
66 </xsl:template>
67
68 <xsl:template match="gsf:link">
69 <xsl:choose>
70 <xsl:when test="@type='classifier'">
71 <a>
72 <xslt:attribute name='href'>
73 <xslt:value-of select='$library_name'/>
74 <xsl:text>/collection/</xsl:text>
75 <xslt:value-of select='/page/pageResponse/collection/@name'/>
76 <xsl:text>/browse/</xsl:text>
77 <xslt:value-of select='util:replace(@nodeID, ".", "/")'/>
78 </xslt:attribute>
79 <xsl:apply-templates/>
80 </a>
81 </xsl:when>
82 <xsl:when test="@type='source'">
83 <a><xslt:attribute name='href'><xslt:value-of
84 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
85 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='assocfilepath']" />/<xslt:value-of
86 disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='srclinkFile']" /></xslt:attribute>
87 <xsl:apply-templates/>
88 </a>
89 </xsl:when>
90 <xsl:otherwise> <!-- a document link -->
91 <xslt:variable name="bookswitch">
92 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
93 </xslt:variable>
94 <a>
95 <xslt:attribute name="href">
96 <xslt:value-of select='$library_name'/>
97 <xsl:text>/collection/</xsl:text>
98 <xslt:value-of select='/page/pageResponse/collection/@name'/>
99 <xsl:text>/document/</xsl:text>
100 <xslt:value-of select='@nodeID'/>
101 <xslt:choose>
102 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
103 <xsl:text>?book=on</xsl:text>
104 </xslt:when>
105 <xslt:otherwise>
106 <xslt:if test="$opt-doc-link-args">?<xslt:value-of select="$opt-doc-link-args"/></xslt:if>
107 </xslt:otherwise>
108 </xslt:choose>
109 </xslt:attribute>
110 <xsl:apply-templates/>
111 </a>
112 </xsl:otherwise>
113 </xsl:choose>
114 </xsl:template>
115
116 <xsl:template match="gsf:icon">
117 <xsl:choose>
118 <xsl:when test="@type='classifier'">
119 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
120 </xsl:when>
121 <xsl:when test="not(@type) or @type='document'">
122 <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"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_icon_image')"/></xslt:attribute></img>
123 </xsl:when>
124 </xsl:choose>
125 </xsl:template>
126
127 <!-- calls a template in gslib.xsl in order to avoid xsl vs xslt issue -->
128 <!--<xsl:template match="gsf:equivlinkgs3">
129 <xslt:call-template name="equivDocLinks">
130 <xslt:with-param name="count" select="0"/>
131 </xslt:call-template>
132 </xsl:template>-->
133
134 <!-- 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. -->
135 <xsl:template match="gsf:equivlinkgs3">
136 <xslt:variable name="docicon" select="metadataList/metadata[contains(@name, 'equivDocIcon')]"/>
137 <xslt:variable name="docStartlink" select="metadataList/metadata[contains(@name, 'all_*,*_equivDocLink')]"/>
138 <xslt:variable name="docEndlink" select="metadataList/metadata[contains(@name, '/equivDocLink')]"/>
139
140 <xslt:variable name="equivDocLinks" select="java:org.greenstone.gsdl3.util.XSLTUtil.getEquivDocLinks(',',$docicon, $docStartlink, $docEndlink, ' ')" />
141 <xslt:value-of disable-output-escaping="yes" select="$equivDocLinks"/>
142 </xsl:template>
143
144<!--
145In the collection's format statement, could have the following javascript+XSLT in place of
146the gsf:equivlinkgs3 element (which resolves to the XSLT in config_format.xsl and gslib.xsl).
147<xsl:text disable-output-escaping="yes">&lt;script&gt;var equivDocIcon= [ &quot;
148</xsl:text>
149<gsf:metadata name="equivDocIcon" separator="&quot;, &quot;" multiple="true"/>
150<xsl:text disable-output-escaping="yes">&quot;];var equivDocStartLink= [ &quot;
151</xsl:text>
152<gsf:metadata name="equivDocLink" separator="&quot;,&quot;" multiple="true"/>
153<xsl:text disable-output-escaping="yes">&quot;];var equivDocEndLink= [ &quot;
154</xsl:text>
155<gsf:metadata name="/equivDocLink" separator="&quot;,&quot;" multiple="true"/>
156<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;
157</xsl:text>
158-->
159
160 <!-- gsf:cgiparam example, as used by the Enhanced PDF tutorial:
161 <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> -->
162 <xsl:template match="gsf:cgi-param">
163 <xslt:value-of disable-output-escaping="yes" select="/page/pageRequest/paramList/param[@name='s1.{@name}']/@value"/>
164 </xsl:template>
165
166 <!-- A GLI user can use a gsf:displayText element in GS3's Format Features to retrieve
167 a string defined in either collectionConfig.xml or else the interface dictionaries.
168 If the requested string occurs in neither, the request string itself will be output. -->
169 <xsl:template match="gsf:displayText">
170 <xslt:variable name="displaytext">
171 <xsl:call-template name="gsf:displayItem"/>
172 </xslt:variable>
173
174 <xslt:choose>
175 <xslt:when test="$displaytext != ''">
176 <xslt:value-of disable-output-escaping="yes" select="$displaytext"/>
177 </xslt:when>
178 <xslt:otherwise>
179 <xslt:variable name="interfacetxt">
180 <xsl:call-template name="gsf:interfaceText"/>
181 </xslt:variable>
182
183 <xslt:choose>
184 <xslt:when test="$interfacetxt != ''">
185 <xslt:value-of disable-output-escaping="yes" select="$interfacetxt"/>
186 </xslt:when>
187 <xslt:otherwise>
188 <xslt:value-of disable-output-escaping="yes" select="'{@name}'"/>
189 </xslt:otherwise>
190 </xslt:choose>
191 </xslt:otherwise>
192 </xslt:choose>
193 </xsl:template>
194
195 <!-- With gsf:displayItem, a user can request a displayItem from collectionConfig.xml -->
196 <xsl:template match="gsf:displayItem" name="gsf:displayItem">
197 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/displayItem[@name='{@name}']"/>
198 </xsl:template>
199
200 <!-- With gsf:interfaceText, a user can request a string from the interface dictionaries in the current lang -->
201 <xsl:template match="gsf:interfaceText" name="gsf:interfaceText">
202 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, /page/@lang, '{@name}')"/>
203 </xsl:template>
204
205 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
206 <xsl:template match="gsf:metadata">
207 <xslt:variable name="langAtt"><xsl:value-of select="@lang"/></xslt:variable>
208 <xslt:if test="not(@hidden = 'true')">
209 <xslt:value-of disable-output-escaping="yes">
210 <xsl:attribute name="select">
211 <xsl:if test="@format">
212 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
213 <xsl:value-of select="@format"/>
214 <xsl:text>(</xsl:text>
215 </xsl:if>
216 <xsl:choose>
217 <xsl:when test="@type = 'collection'">
218 <xsl:text>/page/pageResponse/collection/metadataList/metadata[@name='</xsl:text>
219 </xsl:when>
220 <xsl:otherwise>
221 <xsl:text>(.//metadataList)[last()]/metadata[@name='</xsl:text>
222 </xsl:otherwise>
223 </xsl:choose>
224 <xsl:apply-templates select="." mode="get-metadata-name"/>
225 <xsl:text>'</xsl:text>
226 <xsl:if test="@lang">
227 <xsl:text> and @lang=$langAtt</xsl:text>
228 </xsl:if>
229 <xsl:text>]</xsl:text>
230 <xsl:if test="@format">
231 <xsl:text>, /page/@lang )</xsl:text>
232 </xsl:if>
233 </xsl:attribute>
234 </xslt:value-of>
235 </xslt:if>
236 </xsl:template>
237
238 <xsl:template match="gsf:metadata" mode="get-metadata-name">
239 <xsl:if test="@pos">
240 <xsl:text>pos</xsl:text>
241 <xsl:value-of select='@pos'/>
242 <xsl:text>_</xsl:text>
243 </xsl:if>
244 <xsl:if test='@select'>
245 <xsl:value-of select='@select'/>
246 <xsl:text>_</xsl:text>
247 </xsl:if>
248 <xsl:if test="@separator">
249 <xsl:text>*</xsl:text>
250 <xsl:value-of select='@separator'/>
251 <xsl:text>*_</xsl:text>
252 </xsl:if>
253 <xsl:value-of select="@name"/>
254 </xsl:template>
255
256 <xsl:template match="gsf:metadata-old" mode="get-metadata-name">
257 <xsl:if test="@multiple='true'">
258 <xsl:text>all_</xsl:text>
259 </xsl:if>
260 <xsl:if test='@select'>
261 <xsl:value-of select='@select'/>
262 <xsl:text>_</xsl:text>
263 </xsl:if>
264 <xsl:if test="@separator">
265 <xsl:text>*</xsl:text>
266 <xsl:value-of select='@separator'/>
267 <xsl:text>*_</xsl:text>
268 </xsl:if>
269 <xsl:value-of select="@name"/>
270 </xsl:template>
271
272 <xsl:template match="gsf:metadata-older">
273 <xslt:value-of disable-output-escaping="yes">
274 <xsl:attribute name="select">
275 <xsl:text>(.//metadataList)[last()]/metadata[@name="</xsl:text>
276 <xsl:choose>
277 <xsl:when test="@select='parent'">
278 <xsl:text>parent_</xsl:text>
279 </xsl:when>
280 <xsl:when test="@select='root'">
281 <xsl:text>root_</xsl:text>
282 </xsl:when>
283 <xsl:when test="@select='ancestors'">
284 <xsl:text>ancestors'</xsl:text>
285 <xsl:value-of select='@separator'/>
286 <xsl:text>'_</xsl:text>
287 </xsl:when>
288 <xsl:when test="@select='siblings'">
289 <xsl:text>siblings_'</xsl:text>
290 <xsl:value-of select='@separator'/>
291 <xsl:text>'_</xsl:text>
292 </xsl:when>
293 </xsl:choose>
294 <xsl:value-of select="@name"/>
295 <xsl:text>"]</xsl:text>
296 </xsl:attribute>
297 </xslt:value-of>
298 </xsl:template>
299
300 <xsl:template match="gsf:text">
301 <xslt:call-template name="documentNodeText"/>
302 </xsl:template>
303
304 <xsl:template match="gsf:choose-metadata">
305 <xslt:choose>
306 <xsl:for-each select="gsf:metadata">
307 <xslt:when>
308 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
309 <xsl:apply-templates select="."/>
310 </xslt:when>
311 </xsl:for-each>
312 <xsl:if test="gsf:default">
313 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
314 </xsl:if>
315 </xslt:choose>
316 </xsl:template>
317
318 <xsl:template match="gsf:switch">
319 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
320 <xslt:variable name="meta"><xsl:choose><xsl:when test="@preprocess"><xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'])"/></xsl:when><xsl:otherwise><xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/></xsl:otherwise></xsl:choose></xslt:variable>
321 <xslt:choose>
322 <xsl:for-each select="gsf:when">
323 <xslt:when test="util:{@test}($meta, '{@test-value}')">
324 <xsl:apply-templates/>
325 </xslt:when>
326 </xsl:for-each>
327 <xsl:if test="gsf:otherwise">
328 <xslt:otherwise>
329 <xsl:apply-templates select="gsf:otherwise/node()"/>
330 </xslt:otherwise>
331 </xsl:if>
332 </xslt:choose>
333 </xsl:template>
334
335 <xsl:template match="*">
336 <xsl:copy>
337 <xsl:copy-of select="@*"/>
338 <xsl:apply-templates/>
339 </xsl:copy>
340 </xsl:template>
341
342</xsl:stylesheet>
343
344
Note: See TracBrowser for help on using the repository browser.