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

Last change on this file since 25881 was 25881, checked in by kjdon, 12 years ago

added a placeholder to add in optional arguments for document links. currently used to add in p.s=TextQuery which is needed for search term highlighting

File size: 10.6 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:choose>
104 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
105 <xsl:text>?book=on</xsl:text>
106 </xslt:when>
107 <xslt:otherwise>
108<xslt:if test="$opt-doc-link-args">?<xslt:value-of select="$opt-doc-link-args"/></xslt:if></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:if test="not(@hidden = 'true')">
170 <xslt:value-of disable-output-escaping="yes">
171 <xsl:attribute name="select">
172 <xsl:if test="@format">
173 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
174 <xsl:value-of select="@format"/>
175 <xsl:text>(</xsl:text>
176 </xsl:if>
177 <xsl:text>(.//metadataList)[last()]/metadata[@name='</xsl:text>
178 <xsl:apply-templates select="." mode="get-metadata-name"/>
179 <xsl:text>']</xsl:text>
180 <xsl:if test="@format">
181 <xsl:text>, /page/@lang )</xsl:text>
182 </xsl:if>
183 </xsl:attribute>
184 </xslt:value-of>
185 </xslt:if>
186 </xsl:template>
187
188 <xsl:template match="gsf:metadata" mode="get-metadata-name">
189 <xsl:if test="@pos">
190 <xsl:text>pos</xsl:text>
191 <xsl:value-of select='@pos'/>
192 <xsl:text>_</xsl:text>
193 </xsl:if>
194 <xsl:if test='@select'>
195 <xsl:value-of select='@select'/>
196 <xsl:text>_</xsl:text>
197 </xsl:if>
198 <xsl:if test="@separator">
199 <xsl:text>*</xsl:text>
200 <xsl:value-of select='@separator'/>
201 <xsl:text>*_</xsl:text>
202 </xsl:if>
203 <xsl:value-of select="@name"/>
204 </xsl:template>
205
206 <xsl:template match="gsf:metadata-old" mode="get-metadata-name">
207 <xsl:if test="@multiple='true'">
208 <xsl:text>all_</xsl:text>
209 </xsl:if>
210 <xsl:if test='@select'>
211 <xsl:value-of select='@select'/>
212 <xsl:text>_</xsl:text>
213 </xsl:if>
214 <xsl:if test="@separator">
215 <xsl:text>*</xsl:text>
216 <xsl:value-of select='@separator'/>
217 <xsl:text>*_</xsl:text>
218 </xsl:if>
219 <xsl:value-of select="@name"/>
220 </xsl:template>
221
222 <xsl:template match="gsf:metadata-older">
223 <xslt:value-of disable-output-escaping="yes">
224 <xsl:attribute name="select">
225 <xsl:text>(.//metadataList)[last()]/metadata[@name="</xsl:text>
226 <xsl:choose>
227 <xsl:when test="@select='parent'">
228 <xsl:text>parent_</xsl:text>
229 </xsl:when>
230 <xsl:when test="@select='root'">
231 <xsl:text>root_</xsl:text>
232 </xsl:when>
233 <xsl:when test="@select='ancestors'">
234 <xsl:text>ancestors'</xsl:text>
235 <xsl:value-of select='@separator'/>
236 <xsl:text>'_</xsl:text>
237 </xsl:when>
238 <xsl:when test="@select='siblings'">
239 <xsl:text>siblings_'</xsl:text>
240 <xsl:value-of select='@separator'/>
241 <xsl:text>'_</xsl:text>
242 </xsl:when>
243 </xsl:choose>
244 <xsl:value-of select="@name"/>
245 <xsl:text>"]</xsl:text>
246 </xsl:attribute>
247 </xslt:value-of>
248 </xsl:template>
249
250 <xsl:template match="gsf:text">
251 <xslt:call-template name="documentNodeText"/>
252 </xsl:template>
253
254 <xsl:template match="gsf:choose-metadata">
255 <xslt:choose>
256 <xsl:for-each select="gsf:metadata">
257 <xslt:when>
258 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
259 <xsl:apply-templates select="."/>
260 </xslt:when>
261 </xsl:for-each>
262 <xsl:if test="gsf:default">
263 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
264 </xsl:if>
265 </xslt:choose>
266 </xsl:template>
267
268 <xsl:template match="gsf:switch">
269 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
270 <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>
271 <xslt:choose>
272 <xsl:for-each select="gsf:when">
273 <xslt:when test="util:{@test}($meta, '{@test-value}')">
274 <xsl:apply-templates/>
275 </xslt:when>
276 </xsl:for-each>
277 <xsl:if test="gsf:otherwise">
278 <xslt:otherwise>
279 <xsl:apply-templates select="gsf:otherwise/node()"/>
280 </xslt:otherwise>
281 </xsl:if>
282 </xslt:choose>
283 </xsl:template>
284
285 <xsl:template match="*">
286 <xsl:copy>
287 <xsl:copy-of select="@*"/>
288 <xsl:apply-templates/>
289 </xsl:copy>
290 </xsl:template>
291
292</xsl:stylesheet>
293
294
Note: See TracBrowser for help on using the repository browser.