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

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

Added an anchor to the end of two of the links

File size: 10.3 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>?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)[last()]/metadata[@name='assocfilepath']" />/<xslt:value-of
95 disable-output-escaping="yes" select="(.//metadataList)[last()]/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 <xsl:text>#</xsl:text>
125 <xslt:value-of select="@nodeID"/>
126 </xslt:attribute>
127 <xsl:apply-templates/>
128 </a>
129 </xslt:when>
130 <xslt:otherwise>
131 <a>
132 <xslt:attribute name="href">
133 <xslt:value-of select='$library_name'/>
134 <xsl:text>?a=d&amp;book=off</xsl:text>
135 <xslt:if test="not(@docType = 'paged')">
136 <xsl:text>&amp;ed=1</xsl:text>
137 </xslt:if>
138 <xsl:text>&amp;c=</xsl:text>
139 <xslt:value-of select='/page/pageResponse/collection/@name'/>
140 <xsl:text>&amp;d=</xsl:text>
141 <xslt:value-of select='@nodeID'/>
142 <xsl:text>&amp;dt=</xsl:text>
143 <xslt:value-of select='@docType'/>
144 <xslt:if test="@nodeType='leaf'">
145 <xsl:text>&amp;sib=1</xsl:text>
146 </xslt:if>
147 <xsl:text>&amp;p.a=</xsl:text>
148 <xslt:value-of select="/page/pageRequest/@action"/>
149 <xsl:text>&amp;p.sa=</xsl:text>
150 <xsl:value-of select="/page/pageRequest/@subaction"/>
151 <xsl:text>&amp;p.s=</xsl:text>
152 <xslt:value-of select="/page/pageResponse/service/@name"/>
153 <xsl:text>#</xsl:text>
154 <xslt:value-of select="@nodeID"/>
155 </xslt:attribute>
156 <xsl:apply-templates/>
157 </a>
158 </xslt:otherwise>
159 </xslt:choose>
160 </xsl:otherwise>
161 </xsl:choose>
162 </xsl:template>
163
164 <xsl:template match="gsf:icon">
165 <xsl:choose>
166 <xsl:when test="@type='classifier'">
167 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
168 </xsl:when>
169 <xsl:when test="@type='document'">
170 <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>
171 </xsl:when>
172 </xsl:choose>
173 </xsl:template>
174
175 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
176 <xsl:template match="gsf:metadata">
177 <xslt:if test="not(@hidden = 'true')">
178 <xslt:value-of disable-output-escaping="yes">
179 <xsl:attribute name="select">
180 <xsl:if test="@format">
181 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
182 <xsl:value-of select="@format"/>
183 <xsl:text>(</xsl:text>
184 </xsl:if>
185 <xsl:text>(.//metadataList)[last()]/metadata[@name='</xsl:text>
186 <xsl:apply-templates select="." mode="get-metadata-name"/>
187 <xsl:text>']</xsl:text>
188 <xsl:if test="@format">
189 <xsl:text>, /page/@lang )</xsl:text>
190 </xsl:if>
191 </xsl:attribute>
192 </xslt:value-of>
193 </xslt:if>
194 </xsl:template>
195
196 <xsl:template match="gsf:metadata" mode="get-metadata-name">
197 <xsl:if test="@multiple='true'">
198 <xsl:text>all_</xsl:text>
199 </xsl:if>
200 <xsl:if test='@select'>
201 <xsl:value-of select='@select'/>
202 <xsl:text>_</xsl:text>
203 </xsl:if>
204 <xsl:if test="@separator">
205 <xsl:text>*</xsl:text>
206 <xsl:value-of select='@separator'/>
207 <xsl:text>*_</xsl:text>
208 </xsl:if>
209 <xsl:value-of select="@name"/>
210 </xsl:template>
211
212 <xsl:template match="gsf:metadata-old">
213 <xslt:value-of disable-output-escaping="yes">
214 <xsl:attribute name="select">
215 <xsl:text>(.//metadataList)[last()]/metadata[@name="</xsl:text>
216 <xsl:choose>
217 <xsl:when test="@select='parent'">
218 <xsl:text>parent_</xsl:text>
219 </xsl:when>
220 <xsl:when test="@select='root'">
221 <xsl:text>root_</xsl:text>
222 </xsl:when>
223 <xsl:when test="@select='ancestors'">
224 <xsl:text>ancestors'</xsl:text>
225 <xsl:value-of select='@separator'/>
226 <xsl:text>'_</xsl:text>
227 </xsl:when>
228 <xsl:when test="@select='siblings'">
229 <xsl:text>siblings_'</xsl:text>
230 <xsl:value-of select='@separator'/>
231 <xsl:text>'_</xsl:text>
232 </xsl:when>
233 </xsl:choose>
234 <xsl:value-of select="@name"/>
235 <xsl:text>"]</xsl:text>
236 </xsl:attribute>
237 </xslt:value-of>
238 </xsl:template>
239
240 <xsl:template match="gsf:text">
241 <xslt:apply-templates select="nodeContent"/>
242 </xsl:template>
243
244 <xsl:template match="gsf:choose-metadata">
245 <xslt:choose>
246 <xsl:for-each select="gsf:metadata">
247 <xslt:when>
248 <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
249 <xsl:apply-templates select="."/>
250 </xslt:when>
251 </xsl:for-each>
252 <xsl:if test="gsf:default">
253 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
254 </xsl:if>
255 </xslt:choose>
256 </xsl:template>
257
258 <xsl:template match="gsf:switch">
259 <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
260 <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>
261 <xslt:choose>
262 <xsl:for-each select="gsf:when">
263 <xslt:when test="util:{@test}($meta, '{@test-value}')">
264 <xsl:apply-templates/>
265 </xslt:when>
266 </xsl:for-each>
267 <xsl:if test="gsf:otherwise">
268 <xslt:otherwise>
269 <xsl:apply-templates select="gsf:otherwise/node()"/>
270 </xslt:otherwise>
271 </xsl:if>
272 </xslt:choose>
273 </xsl:template>
274
275 <xsl:template match="*">
276 <xsl:copy>
277 <xsl:copy-of select="@*"/>
278 <xsl:apply-templates/>
279 </xsl:copy>
280 </xsl:template>
281
282</xsl:stylesheet>
283
284
Note: See TracBrowser for help on using the repository browser.