source: main/trunk/greenstone3/web/interfaces/oran/transform/config_format.xsl@ 25002

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

Added the ability to hide metadata (so that it is only retrieved but not displayed as well as added gsf:image

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="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="/page/pageResponse/document/documentNode/metadataList/metadata[@name = 'Thumb']"/>
57 </xsl:when>
58 <xsl:when test="@type = 'screen'">
59 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode/metadataList/metadata[@name = 'Screen']"/>
60 </xsl:when>
61 <xsl:when test="@type = 'source'">
62 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode/metadataList/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>?a=b&amp;rt=r&amp;s=</xsl:text>
76 <xslt:value-of select='/page/pageResponse/service/@name'/>
77 <xsl:text>&amp;c=</xsl:text>
78 <xslt:value-of select='/page/pageResponse/collection/@name'/>
79 <xsl:text>&amp;cl=</xsl:text>
80 <xslt:value-of select='@nodeID'/>
81 <xslt:if test="classifierNode|documentNode">
82 <xsl:text>.pr</xsl:text>
83 </xslt:if>
84 <xslt:if test="parent::node()[@orientation='horizontal']">
85 <xsl:text>&amp;sib=1</xsl:text>
86 </xslt:if>
87 </xslt:attribute>
88 <xsl:apply-templates/>
89 </a>
90 </xsl:when>
91 <xsl:when test="@type='source'">
92 <a><xslt:attribute name='href'><xslt:value-of
93 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
94 disable-output-escaping="yes" select="metadataList/metadata[@name='assocfilepath']" />/<xslt:value-of
95 disable-output-escaping="yes" select="metadataList/metadata[@name='srclinkFile']" /></xslt:attribute>
96 <xsl:apply-templates/>
97 </a>
98 </xsl:when>
99
100 <xsl:otherwise> <!-- a document link -->
101 <xslt:variable name="bookswitch">
102 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
103 </xslt:variable>
104 <xslt:choose>
105 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
106 <a>
107 <xslt:attribute name="href">
108 <xslt:value-of select='$library_name'/>
109 <xsl:text>?a=d&amp;ed=1&amp;book=on&amp;c=</xsl:text>
110 <xslt:value-of select='/page/pageResponse/collection/@name'/>
111 <xsl:text>&amp;d=</xsl:text>
112 <xslt:value-of select='@nodeID'/>
113 <xsl:text>&amp;dt=</xsl:text>
114 <xslt:value-of select='@docType'/>
115 <xslt:if test="@nodeType='leaf'">
116 <xsl:text>&amp;sib=1</xsl:text>
117 </xslt:if>
118 <xsl:text>&amp;p.a=</xsl:text>
119 <xslt:value-of select="/page/pageRequest/@action"/>
120 <xsl:text>&amp;p.sa=</xsl:text>
121 <xsl:value-of select="/page/pageRequest/@subaction"/>
122 <xsl:text>&amp;p.s=</xsl:text>
123 <xslt:value-of select="/page/pageResponse/service/@name"/>
124 </xslt:attribute>
125 <xsl:apply-templates/>
126 </a>
127 </xslt:when>
128 <xslt:otherwise>
129 <a>
130 <xslt:attribute name="href">
131 <xslt:value-of select='$library_name'/>
132 <xsl:text>?a=d&amp;book=off</xsl:text>
133 <xslt:if test="not(@docType = 'paged')">
134 <xsl:text>&amp;ed=1</xsl:text>
135 </xslt:if>
136 <xsl:text>&amp;c=</xsl:text>
137 <xslt:value-of select='/page/pageResponse/collection/@name'/>
138 <xsl:text>&amp;d=</xsl:text>
139 <xslt:value-of select='@nodeID'/>
140 <xsl:text>&amp;dt=</xsl:text>
141 <xslt:value-of select='@docType'/>
142 <xslt:if test="@nodeType='leaf'">
143 <xsl:text>&amp;sib=1</xsl:text>
144 </xslt:if>
145 <xsl:text>&amp;p.a=</xsl:text>
146 <xslt:value-of select="/page/pageRequest/@action"/>
147 <xsl:text>&amp;p.sa=</xsl:text>
148 <xsl:value-of select="/page/pageRequest/@subaction"/>
149 <xsl:text>&amp;p.s=</xsl:text>
150 <xslt:value-of select="/page/pageResponse/service/@name"/>
151 </xslt:attribute>
152 <xsl:apply-templates/>
153 </a>
154 </xslt:otherwise>
155 </xslt:choose>
156 </xsl:otherwise>
157 </xsl:choose>
158 </xsl:template>
159
160 <xsl:template match="gsf:icon">
161 <xsl:choose>
162 <xsl:when test="@type='classifier'">
163 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
164 </xsl:when>
165 <xsl:when test="@type='document'">
166 <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>
167 </xsl:when>
168 </xsl:choose>
169 </xsl:template>
170
171 <xsl:template match="gsf:metadata[@format]">
172 <xslt:value-of disable-output-escaping="yes">
173 <xsl:attribute name="select">
174 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
175 <xsl:value-of select="@format"/>
176 <xsl:text>(metadataList/metadata[@name='</xsl:text>
177 <xsl:apply-templates select="." mode="get-metadata-name"/>
178 <xsl:text>'], /page/@lang )</xsl:text>
179 </xsl:attribute>
180 </xslt:value-of>
181 </xsl:template>
182
183 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
184 <xsl:template match="xsl:template[@match = 'documentNode' or @match = 'classifierNode']//gsf:metadata | gsf:template[@match = 'documentNode' or @match = 'classifierNode']//gsf:metadata">
185 <xslt:if test="not(@hidden = 'true')">
186 <xslt:value-of disable-output-escaping="yes">
187 <xsl:attribute name="select">
188 <xsl:text>metadataList/metadata[@name='</xsl:text>
189 <xsl:apply-templates select="." mode="get-metadata-name"/>
190 <xsl:text>']</xsl:text>
191 </xsl:attribute>
192 </xslt:value-of>
193 </xslt:if>
194 </xsl:template>
195
196 <xsl:template match="gsf:metadata">
197 <xslt:if test="not(@hidden = 'true')">
198 <xslt:value-of disable-output-escaping="yes">
199 <xsl:attribute name="select">
200 <xsl:text>/page/pageResponse/document/documentNode/metadataList/metadata[@name='</xsl:text>
201 <xsl:apply-templates select="." mode="get-metadata-name"/>
202 <xsl:text>']</xsl:text>
203 </xsl:attribute>
204 </xslt:value-of>
205 </xslt:if>
206 </xsl:template>
207
208 <xsl:template match="gsf:metadata" mode="get-metadata-name">
209 <xsl:if test="@multiple='true'">
210 <xsl:text>all_</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">
225 <xslt:value-of disable-output-escaping="yes">
226 <xsl:attribute name="select">
227 <xsl:text>metadataList/metadata[@name="</xsl:text>
228 <xsl:choose>
229 <xsl:when test="@select='parent'">
230 <xsl:text>parent_</xsl:text>
231 </xsl:when>
232 <xsl:when test="@select='root'">
233 <xsl:text>root_</xsl:text>
234 </xsl:when>
235 <xsl:when test="@select='ancestors'">
236 <xsl:text>ancestors'</xsl:text>
237 <xsl:value-of select='@separator'/>
238 <xsl:text>'_</xsl:text>
239 </xsl:when>
240 <xsl:when test="@select='siblings'">
241 <xsl:text>siblings_'</xsl:text>
242 <xsl:value-of select='@separator'/>
243 <xsl:text>'_</xsl:text>
244 </xsl:when>
245 </xsl:choose>
246 <xsl:value-of select="@name"/>
247 <xsl:text>"]</xsl:text>
248 </xsl:attribute>
249 </xslt:value-of>
250 </xsl:template>
251
252 <xsl:template match="gsf:text">
253 <xslt:apply-templates select="nodeContent"/>
254 </xsl:template>
255
256 <xsl:template match="xsl:template[@match = 'documentNode' or @match = 'classifierNode']//gsf:choose-metadata | gsf:template[@match = 'documentNode' or @match = 'classifierNode']//gsf:choose-metadata">
257 <xslt:choose>
258 <xsl:for-each select="gsf:metadata">
259 <xslt:when>
260 <xsl:attribute name="test">metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
261 <xsl:apply-templates select="."/>
262 </xslt:when>
263 </xsl:for-each>
264 <xsl:if test="gsf:default">
265 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
266 </xsl:if>
267 </xslt:choose>
268 </xsl:template>
269
270 <xsl:template match="gsf:choose-metadata">
271 <xslt:choose>
272 <xsl:for-each select="gsf:metadata">
273 <xslt:when>
274 <xsl:attribute name="test">/page/pageResponse/document/documentNode/metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
275 <xsl:apply-templates select="."/>
276 </xslt:when>
277 </xsl:for-each>
278 <xsl:if test="gsf:default">
279 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
280 </xsl:if>
281 </xslt:choose>
282 </xsl:template>
283
284 <xsl:template match="gsf:switch">
285 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
286 <xslt:variable name="meta"><xsl:choose><xsl:when test="@preprocess"><xslt:value-of select="util:{@preprocess}(metadataList/metadata[@name='{$meta-name}'])"/></xsl:when><xsl:otherwise><xslt:value-of select="metadataList/metadata[@name='{$meta-name}']"/></xsl:otherwise></xsl:choose></xslt:variable>
287 <xslt:choose>
288 <xsl:for-each select="gsf:when">
289 <xslt:when test="util:{@test}($meta, '{@test-value}')">
290 <xsl:apply-templates/>
291 </xslt:when>
292 </xsl:for-each>
293 <xsl:if test="gsf:otherwise">
294 <xslt:otherwise>
295 <xsl:apply-templates select="gsf:otherwise/node()"/>
296 </xslt:otherwise>
297 </xsl:if>
298 </xslt:choose>
299 </xsl:template>
300
301 <xsl:template match="*">
302 <xsl:copy>
303 <xsl:copy-of select="@*"/>
304 <xsl:apply-templates/>
305 </xsl:copy>
306 </xsl:template>
307
308</xsl:stylesheet>
309
310
Note: See TracBrowser for help on using the repository browser.