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

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

Some improvements to the gsf:image statement

File size: 11.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
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 <!-- gsf:cgiparam example, as used by the Enhanced PDF tutorial:
128 <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> -->
129 <xsl:template match="gsf:cgi-param">
130 <xslt:value-of disable-output-escaping="yes" select="/page/pageRequest/paramList/param[@name='s1.{@name}']/@value"/>
131 </xsl:template>
132
133 <!-- A GLI user can use a gsf:displayText element in GS3's Format Features to retrieve
134 a string defined in either collectionConfig.xml or else the interface dictionaries.
135 If the requested string occurs in neither, the request string itself will be output. -->
136 <xsl:template match="gsf:displayText">
137 <xslt:variable name="displaytext">
138 <xsl:call-template name="gsf:displayItem"/>
139 </xslt:variable>
140
141 <xslt:choose>
142 <xslt:when test="$displaytext != ''">
143 <xslt:value-of disable-output-escaping="yes" select="$displaytext"/>
144 </xslt:when>
145 <xslt:otherwise>
146 <xslt:variable name="interfacetxt">
147 <xsl:call-template name="gsf:interfaceText"/>
148 </xslt:variable>
149
150 <xslt:choose>
151 <xslt:when test="$interfacetxt != ''">
152 <xslt:value-of disable-output-escaping="yes" select="$interfacetxt"/>
153 </xslt:when>
154 <xslt:otherwise>
155 <xslt:value-of disable-output-escaping="yes" select="'{@name}'"/>
156 </xslt:otherwise>
157 </xslt:choose>
158 </xslt:otherwise>
159 </xslt:choose>
160 </xsl:template>
161
162 <!-- With gsf:displayItem, a user can request a displayItem from collectionConfig.xml -->
163 <xsl:template match="gsf:displayItem" name="gsf:displayItem">
164 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/displayItem[@name='{@name}']"/>
165 </xsl:template>
166
167 <!-- With gsf:interfaceText, a user can request a string from the interface dictionaries in the current lang -->
168 <xsl:template match="gsf:interfaceText" name="gsf:interfaceText">
169 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, /page/@lang, '{@name}')"/>
170 </xsl:template>
171
172 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
173 <xsl:template match="gsf:metadata">
174 <xslt:variable name="langAtt"><xsl:value-of select="@lang"/></xslt:variable>
175 <xslt:if test="not(@hidden = 'true')">
176 <xslt:value-of disable-output-escaping="yes">
177 <xsl:attribute name="select">
178 <xsl:if test="@format">
179 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
180 <xsl:value-of select="@format"/>
181 <xsl:text>(</xsl:text>
182 </xsl:if>
183 <xsl:choose>
184 <xsl:when test="@type = 'collection'">
185 <xsl:text>/page/pageResponse/collection/metadataList/metadata[@name='</xsl:text>
186 </xsl:when>
187 <xsl:otherwise>
188 <xsl:text>(.//metadataList)[last()]/metadata[@name='</xsl:text>
189 </xsl:otherwise>
190 </xsl:choose>
191 <xsl:apply-templates select="." mode="get-metadata-name"/>
192 <xsl:text>'</xsl:text>
193 <xsl:if test="@lang">
194 <xsl:text> and @lang=$langAtt</xsl:text>
195 </xsl:if>
196 <xsl:text>]</xsl:text>
197 <xsl:if test="@format">
198 <xsl:text>, /page/@lang )</xsl:text>
199 </xsl:if>
200 </xsl:attribute>
201 </xslt:value-of>
202 </xslt:if>
203 </xsl:template>
204
205 <xsl:template match="gsf:metadata" mode="get-metadata-name">
206 <xsl:if test="@pos">
207 <xsl:text>pos</xsl:text>
208 <xsl:value-of select='@pos'/>
209 <xsl:text>_</xsl:text>
210 </xsl:if>
211 <xsl:if test='@select'>
212 <xsl:value-of select='@select'/>
213 <xsl:text>_</xsl:text>
214 </xsl:if>
215 <xsl:if test="@separator">
216 <xsl:text>*</xsl:text>
217 <xsl:value-of select='@separator'/>
218 <xsl:text>*_</xsl:text>
219 </xsl:if>
220 <xsl:value-of select="@name"/>
221 </xsl:template>
222
223 <xsl:template match="gsf:metadata-old" mode="get-metadata-name">
224 <xsl:if test="@multiple='true'">
225 <xsl:text>all_</xsl:text>
226 </xsl:if>
227 <xsl:if test='@select'>
228 <xsl:value-of select='@select'/>
229 <xsl:text>_</xsl:text>
230 </xsl:if>
231 <xsl:if test="@separator">
232 <xsl:text>*</xsl:text>
233 <xsl:value-of select='@separator'/>
234 <xsl:text>*_</xsl:text>
235 </xsl:if>
236 <xsl:value-of select="@name"/>
237 </xsl:template>
238
239 <xsl:template match="gsf:metadata-older">
240 <xslt:value-of disable-output-escaping="yes">
241 <xsl:attribute name="select">
242 <xsl:text>(.//metadataList)[last()]/metadata[@name="</xsl:text>
243 <xsl:choose>
244 <xsl:when test="@select='parent'">
245 <xsl:text>parent_</xsl:text>
246 </xsl:when>
247 <xsl:when test="@select='root'">
248 <xsl:text>root_</xsl:text>
249 </xsl:when>
250 <xsl:when test="@select='ancestors'">
251 <xsl:text>ancestors'</xsl:text>
252 <xsl:value-of select='@separator'/>
253 <xsl:text>'_</xsl:text>
254 </xsl:when>
255 <xsl:when test="@select='siblings'">
256 <xsl:text>siblings_'</xsl:text>
257 <xsl:value-of select='@separator'/>
258 <xsl:text>'_</xsl:text>
259 </xsl:when>
260 </xsl:choose>
261 <xsl:value-of select="@name"/>
262 <xsl:text>"]</xsl:text>
263 </xsl:attribute>
264 </xslt:value-of>
265 </xsl:template>
266
267 <xsl:template match="gsf:text">
268 <xslt:call-template name="documentNodeText"/>
269 </xsl:template>
270
271 <xsl:template match="gsf:choose-metadata">
272 <xslt:choose>
273 <xsl:for-each select="gsf:metadata">
274 <xslt:when>
275 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
276 <xsl:apply-templates select="."/>
277 </xslt:when>
278 </xsl:for-each>
279 <xsl:if test="gsf:default">
280 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
281 </xsl:if>
282 </xslt:choose>
283 </xsl:template>
284
285 <xsl:template match="gsf:switch">
286 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
287 <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>
288 <xslt:choose>
289 <xsl:for-each select="gsf:when">
290 <xslt:when test="util:{@test}($meta, '{@test-value}')">
291 <xsl:apply-templates/>
292 </xslt:when>
293 </xsl:for-each>
294 <xsl:if test="gsf:otherwise">
295 <xslt:otherwise>
296 <xsl:apply-templates select="gsf:otherwise/node()"/>
297 </xslt:otherwise>
298 </xsl:if>
299 </xslt:choose>
300 </xsl:template>
301
302 <xsl:template match="*">
303 <xsl:copy>
304 <xsl:copy-of select="@*"/>
305 <xsl:apply-templates/>
306 </xsl:copy>
307 </xsl:template>
308
309</xsl:stylesheet>
310
311
Note: See TracBrowser for help on using the repository browser.