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

Last change on this file since 25941 was 25941, checked in by ak19, 12 years ago

Introducing gsf:cgi-param since the Enhanced PDF tutorial uses it for search query highlighting in Acrobat when on Windows.

File size: 11.5 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 <img>
49 <xslt:attribute name='src'>
50 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
51 <xsl:text>/index/assoc/</xsl:text>
52 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name = 'assocfilepath']"/>
53 <xsl:text>/</xsl:text>
54 <xsl:choose>
55 <xsl:when test="@type = 'thumb'">
56 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'Thumb']"/>
57 </xsl:when>
58 <xsl:when test="@type = 'screen'">
59 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'Screen']"/>
60 </xsl:when>
61 <xsl:when test="@type = 'source'">
62 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'SourceFile']"/>
63 </xsl:when>
64 </xsl:choose>
65 </xslt:attribute>
66 </img>
67 </xsl:template>
68
69 <xsl:template match="gsf:link">
70 <xsl:choose>
71 <xsl:when test="@type='classifier'">
72 <a>
73 <xslt:attribute name='href'>
74 <xslt:value-of select='$library_name'/>
75 <xsl:text>/collection/</xsl:text>
76 <xslt:value-of select='/page/pageResponse/collection/@name'/>
77 <xsl:text>/browse/</xsl:text>
78 <xslt:value-of select='util:replace(@nodeID, ".", "/")'/>
79 </xslt:attribute>
80 <xsl:apply-templates/>
81 </a>
82 </xsl:when>
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
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>
88 <xsl:apply-templates/>
89 </a>
90 </xsl:when>
91 <xsl:otherwise> <!-- a document link -->
92 <xslt:variable name="bookswitch">
93 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
94 </xslt:variable>
95 <a>
96 <xslt:attribute name="href">
97 <xslt:value-of select='$library_name'/>
98 <xsl:text>/collection/</xsl:text>
99 <xslt:value-of select='/page/pageResponse/collection/@name'/>
100 <xsl:text>/document/</xsl:text>
101 <xslt:value-of select='@nodeID'/>
102 <xslt:choose>
103 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
104 <xsl:text>?book=on</xsl:text>
105 </xslt:when>
106 <xslt:otherwise>
107 <xslt:if test="$opt-doc-link-args">?<xslt:value-of select="$opt-doc-link-args"/></xslt:if>
108 </xslt:otherwise>
109 </xslt:choose>
110 </xslt:attribute>
111 <xsl:apply-templates/>
112 </a>
113 </xsl:otherwise>
114 </xsl:choose>
115 </xsl:template>
116
117 <xsl:template match="gsf:icon">
118 <xsl:choose>
119 <xsl:when test="@type='classifier'">
120 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
121 </xsl:when>
122 <xsl:when test="not(@type) or @type='document'">
123 <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>
124 </xsl:when>
125 </xsl:choose>
126 </xsl:template>
127
128 <!-- gsf:cgiparam example, as used by the Enhanced PDF tutorial:
129 <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> -->
130 <xsl:template match="gsf:cgi-param">
131 <xslt:value-of disable-output-escaping="yes" select="/page/pageRequest/paramList/param[@name='s1.{@name}']/@value"/>
132 </xsl:template>
133
134 <!-- A GLI user can use a gsf:displayText element in GS3's Format Features to retrieve
135 a string defined in either collectionConfig.xml or else the interface dictionaries.
136 If the requested string occurs in neither, the request string itself will be output. -->
137 <xsl:template match="gsf:displayText">
138 <xslt:variable name="displaytext">
139 <xsl:call-template name="gsf:displayItem"/>
140 </xslt:variable>
141
142 <xslt:choose>
143 <xslt:when test="$displaytext != ''">
144 <xslt:value-of disable-output-escaping="yes" select="$displaytext"/>
145 </xslt:when>
146 <xslt:otherwise>
147 <xslt:variable name="interfacetxt">
148 <xsl:call-template name="gsf:interfaceText"/>
149 </xslt:variable>
150
151 <xslt:choose>
152 <xslt:when test="$interfacetxt != ''">
153 <xslt:value-of disable-output-escaping="yes" select="$interfacetxt"/>
154 </xslt:when>
155 <xslt:otherwise>
156 <xslt:value-of disable-output-escaping="yes" select="'{@name}'"/>
157 </xslt:otherwise>
158 </xslt:choose>
159 </xslt:otherwise>
160 </xslt:choose>
161 </xsl:template>
162
163 <!-- With gsf:displayItem, a user can request a displayItem from collectionConfig.xml -->
164 <xsl:template match="gsf:displayItem" name="gsf:displayItem">
165 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/displayItem[@name='{@name}']"/>
166 </xsl:template>
167
168 <!-- With gsf:interfaceText, a user can request a string from the interface dictionaries in the current lang -->
169 <xsl:template match="gsf:interfaceText" name="gsf:interfaceText">
170 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, /page/@lang, '{@name}')"/>
171 </xsl:template>
172
173 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
174 <xsl:template match="gsf:metadata">
175 <xslt:variable name="langAtt"><xsl:value-of select="@lang"/></xslt:variable>
176 <xslt:if test="not(@hidden = 'true')">
177 <xslt:value-of disable-output-escaping="yes">
178 <xsl:attribute name="select">
179 <xsl:if test="@format">
180 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
181 <xsl:value-of select="@format"/>
182 <xsl:text>(</xsl:text>
183 </xsl:if>
184 <xsl:choose>
185 <xsl:when test="@type = 'collection'">
186 <xsl:text>/page/pageResponse/collection/metadataList/metadata[@name='</xsl:text>
187 </xsl:when>
188 <xsl:otherwise>
189 <xsl:text>(.//metadataList)[last()]/metadata[@name='</xsl:text>
190 </xsl:otherwise>
191 </xsl:choose>
192 <xsl:apply-templates select="." mode="get-metadata-name"/>
193 <xsl:text>'</xsl:text>
194 <xsl:if test="@lang">
195 <xsl:text> and @lang=$langAtt</xsl:text>
196 </xsl:if>
197 <xsl:text>]</xsl:text>
198 <xsl:if test="@format">
199 <xsl:text>, /page/@lang )</xsl:text>
200 </xsl:if>
201 </xsl:attribute>
202 </xslt:value-of>
203 </xslt:if>
204 </xsl:template>
205
206 <xsl:template match="gsf:metadata" mode="get-metadata-name">
207 <xsl:if test="@pos">
208 <xsl:text>pos</xsl:text>
209 <xsl:value-of select='@pos'/>
210 <xsl:text>_</xsl:text>
211 </xsl:if>
212 <xsl:if test='@select'>
213 <xsl:value-of select='@select'/>
214 <xsl:text>_</xsl:text>
215 </xsl:if>
216 <xsl:if test="@separator">
217 <xsl:text>*</xsl:text>
218 <xsl:value-of select='@separator'/>
219 <xsl:text>*_</xsl:text>
220 </xsl:if>
221 <xsl:value-of select="@name"/>
222 </xsl:template>
223
224 <xsl:template match="gsf:metadata-old" mode="get-metadata-name">
225 <xsl:if test="@multiple='true'">
226 <xsl:text>all_</xsl:text>
227 </xsl:if>
228 <xsl:if test='@select'>
229 <xsl:value-of select='@select'/>
230 <xsl:text>_</xsl:text>
231 </xsl:if>
232 <xsl:if test="@separator">
233 <xsl:text>*</xsl:text>
234 <xsl:value-of select='@separator'/>
235 <xsl:text>*_</xsl:text>
236 </xsl:if>
237 <xsl:value-of select="@name"/>
238 </xsl:template>
239
240 <xsl:template match="gsf:metadata-older">
241 <xslt:value-of disable-output-escaping="yes">
242 <xsl:attribute name="select">
243 <xsl:text>(.//metadataList)[last()]/metadata[@name="</xsl:text>
244 <xsl:choose>
245 <xsl:when test="@select='parent'">
246 <xsl:text>parent_</xsl:text>
247 </xsl:when>
248 <xsl:when test="@select='root'">
249 <xsl:text>root_</xsl:text>
250 </xsl:when>
251 <xsl:when test="@select='ancestors'">
252 <xsl:text>ancestors'</xsl:text>
253 <xsl:value-of select='@separator'/>
254 <xsl:text>'_</xsl:text>
255 </xsl:when>
256 <xsl:when test="@select='siblings'">
257 <xsl:text>siblings_'</xsl:text>
258 <xsl:value-of select='@separator'/>
259 <xsl:text>'_</xsl:text>
260 </xsl:when>
261 </xsl:choose>
262 <xsl:value-of select="@name"/>
263 <xsl:text>"]</xsl:text>
264 </xsl:attribute>
265 </xslt:value-of>
266 </xsl:template>
267
268 <xsl:template match="gsf:text">
269 <xslt:call-template name="documentNodeText"/>
270 </xsl:template>
271
272 <xsl:template match="gsf:choose-metadata">
273 <xslt:choose>
274 <xsl:for-each select="gsf:metadata">
275 <xslt:when>
276 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
277 <xsl:apply-templates select="."/>
278 </xslt:when>
279 </xsl:for-each>
280 <xsl:if test="gsf:default">
281 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
282 </xsl:if>
283 </xslt:choose>
284 </xsl:template>
285
286 <xsl:template match="gsf:switch">
287 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
288 <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>
289 <xslt:choose>
290 <xsl:for-each select="gsf:when">
291 <xslt:when test="util:{@test}($meta, '{@test-value}')">
292 <xsl:apply-templates/>
293 </xslt:when>
294 </xsl:for-each>
295 <xsl:if test="gsf:otherwise">
296 <xslt:otherwise>
297 <xsl:apply-templates select="gsf:otherwise/node()"/>
298 </xslt:otherwise>
299 </xsl:if>
300 </xslt:choose>
301 </xsl:template>
302
303 <xsl:template match="*">
304 <xsl:copy>
305 <xsl:copy-of select="@*"/>
306 <xsl:apply-templates/>
307 </xsl:copy>
308 </xsl:template>
309
310</xsl:stylesheet>
311
312
Note: See TracBrowser for help on using the repository browser.