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

Last change on this file since 24792 was 24792, checked in by sjm84, 13 years ago

gsf:metadata statements will now work out where to get metadata from based on their current context, instead of always assuming that they are in a documentNode or a classifierNode

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:link">
48 <xsl:choose>
49 <xsl:when test="@type='classifier'">
50 <a>
51 <xslt:attribute name='href'>
52 <xslt:value-of select='$library_name'/>
53 <xsl:text>?a=b&amp;rt=r&amp;s=</xsl:text>
54 <xslt:value-of select='/page/pageResponse/service/@name'/>
55 <xsl:text>&amp;c=</xsl:text>
56 <xslt:value-of select='/page/pageResponse/collection/@name'/>
57 <xsl:text>&amp;cl=</xsl:text>
58 <xslt:value-of select='@nodeID'/>
59 <xslt:if test="classifierNode|documentNode">
60 <xsl:text>.pr</xsl:text>
61 </xslt:if>
62 <xslt:if test="parent::node()[@orientation='horizontal']">
63 <xsl:text>&amp;sib=1</xsl:text>
64 </xslt:if>
65 </xslt:attribute>
66 <xsl:apply-templates/>
67 </a>
68 </xsl:when>
69 <xsl:when test="@type='source'">
70 <a><xslt:attribute name='href'><xslt:value-of
71 disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
72 disable-output-escaping="yes" select="metadataList/metadata[@name='assocfilepath']" />/<xslt:value-of
73 disable-output-escaping="yes" select="metadataList/metadata[@name='srclinkFile']" /></xslt:attribute>
74 <xsl:apply-templates/>
75 </a>
76 </xsl:when>
77
78 <xsl:otherwise> <!-- a document link -->
79 <xslt:variable name="bookswitch">
80 <xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
81 </xslt:variable>
82 <xslt:choose>
83 <xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
84 <a>
85 <xslt:attribute name="href">
86 <xslt:value-of select='$library_name'/>
87 <xsl:text>?a=d&amp;ed=1&amp;book=on&amp;c=</xsl:text>
88 <xslt:value-of select='/page/pageResponse/collection/@name'/>
89 <xsl:text>&amp;d=</xsl:text>
90 <xslt:value-of select='@nodeID'/>
91 <xsl:text>&amp;dt=</xsl:text>
92 <xslt:value-of select='@docType'/>
93 <xslt:if test="@nodeType='leaf'">
94 <xsl:text>&amp;sib=1</xsl:text>
95 </xslt:if>
96 <xsl:text>&amp;p.a=</xsl:text>
97 <xslt:value-of select="/page/pageRequest/@action"/>
98 <xsl:text>&amp;p.sa=</xsl:text>
99 <xsl:value-of select="/page/pageRequest/@subaction"/>
100 <xsl:text>&amp;p.s=</xsl:text>
101 <xslt:value-of select="/page/pageResponse/service/@name"/>
102 </xslt:attribute>
103 <xsl:apply-templates/>
104 </a>
105 </xslt:when>
106 <xslt:otherwise>
107 <a>
108 <xslt:attribute name="href">
109 <xslt:value-of select='$library_name'/>
110 <xsl:text disable-output-escaping="yes">?a=d&amp;ed=1&amp;book=off&amp;c=</xsl:text>
111 <xslt:value-of select='/page/pageResponse/collection/@name'/>
112 <xsl:text disable-output-escaping="yes">&amp;d=</xsl:text>
113 <xslt:value-of select='@nodeID'/>
114 <xsl:text disable-output-escaping="yes">&amp;dt=</xsl:text>
115 <xslt:value-of select='@docType'/>
116 <xslt:if test="@nodeType='leaf'">
117 <xsl:text disable-output-escaping="yes">&amp;sib=1</xsl:text>
118 </xslt:if>
119 <xsl:text disable-output-escaping="yes">&amp;p.a=</xsl:text>
120 <xslt:value-of select="/page/pageRequest/@action"/>
121 <xsl:text disable-output-escaping="yes">&amp;p.sa=</xsl:text>
122 <xsl:value-of select="/page/pageRequest/@subaction"/>
123 <xsl:text disable-output-escaping="yes">&amp;p.s=</xsl:text>
124 <xslt:value-of select="/page/pageResponse/service/@name"/>
125 </xslt:attribute>
126 <xsl:apply-templates/>
127 </a>
128 </xslt:otherwise>
129 </xslt:choose>
130 </xsl:otherwise>
131 </xsl:choose>
132 </xsl:template>
133
134 <xsl:template match="gsf:icon">
135 <xsl:choose>
136 <xsl:when test="@type='classifier'">
137 <img style="border:0px"><xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'bookshelf_image')"/></xsl:attribute></img>
138 </xsl:when>
139 <xsl:when test="@type='document'">
140 <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>
141 </xsl:when>
142 </xsl:choose>
143 </xsl:template>
144
145 <xsl:template match="gsf:metadata[@format]">
146 <xslt:value-of disable-output-escaping="yes">
147 <xsl:attribute name="select">
148 <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
149 <xsl:value-of select="@format"/>
150 <xsl:text>(metadataList/metadata[@name='</xsl:text>
151 <xsl:apply-templates select="." mode="get-metadata-name"/>
152 <xsl:text>'], /page/@lang )</xsl:text>
153 </xsl:attribute>
154 </xslt:value-of>
155 </xsl:template>
156
157 <!-- if this gsf:metadata is a child of a document node then we want to get the metadata for that node -->
158 <xsl:template match="xsl:template[@match = 'documentNode' or @match = 'classifierNode']//gsf:metadata | gsf:template[@match = 'documentNode' or @match = 'classifierNode']//gsf:metadata">
159 <xslt:value-of disable-output-escaping="yes">
160 <xsl:attribute name="select">
161 <xsl:text>metadataList/metadata[@name='</xsl:text>
162 <xsl:apply-templates select="." mode="get-metadata-name"/>
163 <xsl:text>']</xsl:text>
164 </xsl:attribute>
165 </xslt:value-of>
166 </xsl:template>
167
168 <xsl:template match="gsf:metadata">
169 <xslt:value-of disable-output-escaping="yes">
170 <xsl:attribute name="select">
171 <xsl:text>/page/pageResponse/document/documentNode/metadataList/metadata[@name='</xsl:text>
172 <xsl:apply-templates select="." mode="get-metadata-name"/>
173 <xsl:text>']</xsl:text>
174 </xsl:attribute>
175 </xslt:value-of>
176 </xsl:template>
177
178 <xsl:template match="gsf:metadata" mode="get-metadata-name">
179 <xsl:if test="@multiple='true'">
180 <xsl:text>all_</xsl:text>
181 </xsl:if>
182 <xsl:if test='@select'>
183 <xsl:value-of select='@select'/>
184 <xsl:text>_</xsl:text>
185 </xsl:if>
186 <xsl:if test="@separator">
187 <xsl:text>*</xsl:text>
188 <xsl:value-of select='@separator'/>
189 <xsl:text>*_</xsl:text>
190 </xsl:if>
191 <xsl:value-of select="@name"/>
192 </xsl:template>
193
194 <xsl:template match="gsf:metadata-old">
195 <xslt:value-of disable-output-escaping="yes">
196 <xsl:attribute name="select">
197 <xsl:text>metadataList/metadata[@name="</xsl:text>
198 <xsl:choose>
199 <xsl:when test="@select='parent'">
200 <xsl:text>parent_</xsl:text>
201 </xsl:when>
202 <xsl:when test="@select='root'">
203 <xsl:text>root_</xsl:text>
204 </xsl:when>
205 <xsl:when test="@select='ancestors'">
206 <xsl:text>ancestors'</xsl:text>
207 <xsl:value-of select='@separator'/>
208 <xsl:text>'_</xsl:text>
209 </xsl:when>
210 <xsl:when test="@select='siblings'">
211 <xsl:text>siblings_'</xsl:text>
212 <xsl:value-of select='@separator'/>
213 <xsl:text>'_</xsl:text>
214 </xsl:when>
215 </xsl:choose>
216 <xsl:value-of select="@name"/>
217 <xsl:text>"]</xsl:text>
218 </xsl:attribute>
219 </xslt:value-of>
220 </xsl:template>
221
222 <xsl:template match="gsf:text">
223 <xslt:apply-templates select="nodeContent"/>
224 </xsl:template>
225
226 <xsl:template match="xsl:template[@match = 'documentNode' or @match = 'classifierNode']//gsf:choose-metadata | gsf:template[@match = 'documentNode' or @match = 'classifierNode']//gsf:choose-metadata">
227 <xslt:choose>
228 <xsl:for-each select="gsf:metadata">
229 <xslt:when>
230 <xsl:attribute name="test">metadataList/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
231 <xsl:apply-templates select="."/>
232 </xslt:when>
233 </xsl:for-each>
234 <xsl:if test="gsf:default">
235 <xslt:otherwise><xsl:apply-templates select="gsf:default"/></xslt:otherwise>
236 </xsl:if>
237 </xslt:choose>
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">/page/pageResponse/document/documentNode/metadataList/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/metadata[@name='{$meta-name}'])"/></xsl:when><xsl:otherwise><xslt:value-of select="metadataList/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.