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

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

Asking for a piece of metadata like dc.Creator returns all values for dc.Creator. So multiple=true is always the case by default. No multiple=false was defined. Moreover, there was no way of getting a single value, which was the default in GS2 and which returned the first value for the requested metadata. Now multiple is no longer used, as all values are (still) returned by default. Instead the pos attribute has been introduced, which can be the terms first or last, or else it can be a number representing which value for that metadata needs to be returned.

File size: 10.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 <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
92 <xsl:otherwise> <!-- a document link -->
93 <xslt:variable name="bookswitch">
94 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
95 </xslt:variable>
96 <a>
97 <xslt:attribute name="href">
98 <xslt:value-of select='$library_name'/>
99 <xsl:text>/collection/</xsl:text>
100 <xslt:value-of select='/page/pageResponse/collection/@name'/>
101 <xsl:text>/document/</xsl:text>
102 <xslt:value-of select='@nodeID'/>
103 <xslt:if test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
104 <xsl:text>?book=on</xsl:text>
105 </xslt:if>
106 </xslt:attribute>
107 <xsl:apply-templates/>
108 </a>
109 </xsl:otherwise>
110 </xsl:choose>
111 </xsl:template>
112
113 <xsl:template match="gsf:icon">
114 <xsl:choose>
115 <xsl:when test="@type='classifier'">
116 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
117 </xsl:when>
118 <xsl:when test="not(@type) or @type='document'">
119 <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>
120 </xsl:when>
121 </xsl:choose>
122 </xsl:template>
123
124 <!-- A GLI user can use a gsf:displayText element in GS3's Format Features to retrieve
125 a string defined in either collectionConfig.xml or else the interface dictionaries.
126 If the requested string occurs in neither, the request string itself will be output. -->
127 <xsl:template match="gsf:displayText">
128 <xslt:variable name="displaytext">
129 <xsl:call-template name="gsf:displayItem"/>
130 </xslt:variable>
131
132 <xslt:choose>
133 <xslt:when test="$displaytext != ''">
134 <xslt:value-of disable-output-escaping="yes" select="$displaytext"/>
135 </xslt:when>
136 <xslt:otherwise>
137 <xslt:variable name="interfacetxt">
138 <xsl:call-template name="gsf:interfaceText"/>
139 </xslt:variable>
140
141 <xslt:choose>
142 <xslt:when test="$interfacetxt != ''">
143 <xslt:value-of disable-output-escaping="yes" select="$interfacetxt"/>
144 </xslt:when>
145 <xslt:otherwise>
146 <xslt:value-of disable-output-escaping="yes" select="'{@name}'"/>
147 </xslt:otherwise>
148 </xslt:choose>
149 </xslt:otherwise>
150 </xslt:choose>
151 </xsl:template>
152
153 <!-- With gsf:displayItem, a user can request a displayItem from collectionConfig.xml -->
154 <xsl:template match="gsf:displayItem" name="gsf:displayItem">
155 <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/displayItem[@name='{@name}']"/>
156 </xsl:template>
157
158 <!-- With gsf:interfaceText, a user can request a string from the interface dictionaries in the current lang -->
159 <xsl:template match="gsf:interfaceText" name="gsf:interfaceText">
160 <xslt:value-of disable-output-escaping="yes" select="util:getInterfaceText($interface_name, /page/@lang, '{@name}')"/>
161 </xsl:template>
162
163 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
164 <xsl:template match="gsf:metadata">
165 <xslt:if test="not(@hidden = 'true')">
166 <xslt:value-of disable-output-escaping="yes">
167 <xsl:attribute name="select">
168 <xsl:if test="@format">
169 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
170 <xsl:value-of select="@format"/>
171 <xsl:text>(</xsl:text>
172 </xsl:if>
173 <xsl:text>(.//metadataList)[last()]/metadata[@name='</xsl:text>
174 <xsl:apply-templates select="." mode="get-metadata-name"/>
175 <xsl:text>']</xsl:text>
176 <xsl:if test="@format">
177 <xsl:text>, /page/@lang )</xsl:text>
178 </xsl:if>
179 </xsl:attribute>
180 </xslt:value-of>
181 </xslt:if>
182 </xsl:template>
183
184 <xsl:template match="gsf:metadata" mode="get-metadata-name">
185 <xsl:if test="@pos">
186 <xsl:text>pos</xsl:text>
187 <xsl:value-of select='@pos'/>
188 <xsl:text>_</xsl:text>
189 </xsl:if>
190 <xsl:if test='@select'>
191 <xsl:value-of select='@select'/>
192 <xsl:text>_</xsl:text>
193 </xsl:if>
194 <xsl:if test="@separator">
195 <xsl:text>*</xsl:text>
196 <xsl:value-of select='@separator'/>
197 <xsl:text>*_</xsl:text>
198 </xsl:if>
199 <xsl:value-of select="@name"/>
200 </xsl:template>
201
202 <xsl:template match="gsf:metadata-old" mode="get-metadata-name">
203 <xsl:if test="@multiple='true'">
204 <xsl:text>all_</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-older">
219 <xslt:value-of disable-output-escaping="yes">
220 <xsl:attribute name="select">
221 <xsl:text>(.//metadataList)[last()]/metadata[@name="</xsl:text>
222 <xsl:choose>
223 <xsl:when test="@select='parent'">
224 <xsl:text>parent_</xsl:text>
225 </xsl:when>
226 <xsl:when test="@select='root'">
227 <xsl:text>root_</xsl:text>
228 </xsl:when>
229 <xsl:when test="@select='ancestors'">
230 <xsl:text>ancestors'</xsl:text>
231 <xsl:value-of select='@separator'/>
232 <xsl:text>'_</xsl:text>
233 </xsl:when>
234 <xsl:when test="@select='siblings'">
235 <xsl:text>siblings_'</xsl:text>
236 <xsl:value-of select='@separator'/>
237 <xsl:text>'_</xsl:text>
238 </xsl:when>
239 </xsl:choose>
240 <xsl:value-of select="@name"/>
241 <xsl:text>"]</xsl:text>
242 </xsl:attribute>
243 </xslt:value-of>
244 </xsl:template>
245
246 <xsl:template match="gsf:text">
247 <xslt:apply-templates select="nodeContent"/>
248 </xsl:template>
249
250 <xsl:template match="gsf:choose-metadata">
251 <xslt:choose>
252 <xsl:for-each select="gsf:metadata">
253 <xslt:when>
254 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
255 <xsl:apply-templates select="."/>
256 </xslt:when>
257 </xsl:for-each>
258 <xsl:if test="gsf:default">
259 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
260 </xsl:if>
261 </xslt:choose>
262 </xsl:template>
263
264 <xsl:template match="gsf:switch">
265 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
266 <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>
267 <xslt:choose>
268 <xsl:for-each select="gsf:when">
269 <xslt:when test="util:{@test}($meta, '{@test-value}')">
270 <xsl:apply-templates/>
271 </xslt:when>
272 </xsl:for-each>
273 <xsl:if test="gsf:otherwise">
274 <xslt:otherwise>
275 <xsl:apply-templates select="gsf:otherwise/node()"/>
276 </xslt:otherwise>
277 </xsl:if>
278 </xslt:choose>
279 </xsl:template>
280
281 <xsl:template match="*">
282 <xsl:copy>
283 <xsl:copy-of select="@*"/>
284 <xsl:apply-templates/>
285 </xsl:copy>
286 </xsl:template>
287
288</xsl:stylesheet>
289
290
Note: See TracBrowser for help on using the repository browser.