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

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

Some major upgrades to the document view

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