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

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

Adding the type="metadata" attribute will allow users to specify collection level metadata

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