source: main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl@ 22569

Last change on this file since 22569 was 22569, checked in by sjb48, 14 years ago

More work on javascript DOM manipulation using sortables and draggables

File size: 16.8 KB
Line 
1<!--
2Copyright (c) 2001-2009, Evan Lenz
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 * Neither the name of Lenz Consulting Group nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
11 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
13Recent changes:
14
152010-06-10: Added the $force-exclude-all-namespaces parameter
162009-10-19: Added the $exclude-these-namespaces parameter
172009-10-08: Added $att-value parameter and template name to template rule for attributes.
18
19-->
20<xsl:stylesheet version="1.0"
21 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
23 xmlns:exsl="http://exslt.org/common"
24 extension-element-prefixes="exsl" >
25
26 <xsl:output omit-xml-declaration="yes"/>
27
28 <xsl:template name="xml-to-gui">
29 <xsl:param name="node-set" select="."/>
30 <xsl:param name="metadataSets" select="."/>
31
32 <xsl:value-of select="metadataSets[@name]"/>
33 <xsl:apply-templates select="$node-set" mode="xml-to-gui">
34 <xsl:with-param name="depth" select="1"/>
35 <xsl:with-param name="metadataSets" select="$metadataSets"/>
36 </xsl:apply-templates>
37 </xsl:template>
38
39 <xsl:template match="/" mode="xml-to-gui">
40 <xsl:param name="depth"/>
41 <xsl:param name="metadataSets"/>
42
43 <xsl:apply-templates mode="xml-to-gui">
44 <xsl:with-param name="depth" select="$depth"/>
45 <xsl:with-param name="metadataSets" select="$metadataSets"/>
46 </xsl:apply-templates>
47 </xsl:template>
48 <!-- **************************************************************************** -->
49
50 <!-- **************************************************************************** -->
51 <!-- COMBO BOX CREATION -->
52 <!-- **************************************************************************** -->
53
54 <xsl:template name="meta-to-combo">
55 <xsl:param name="metadataSets" select='.'/>
56 <xsl:param name="current" select='.'/>
57
58 <xsl:variable name="current_mod">
59 <xsl:choose>
60 <xsl:when test="contains($current,'.')"><xsl:value-of select="$current"/></xsl:when>
61 <xsl:otherwise>ex.<xsl:value-of select="$current"/></xsl:otherwise>
62 </xsl:choose>
63 </xsl:variable>
64
65 <select>
66 <option value ="{$current_mod}" disabled="disabled" selected="{$current_mod}"><xsl:value-of select="$current_mod"/></option>
67
68 <xsl:apply-templates select="$metadataSets" mode="meta-to-combo">
69 <xsl:with-param name="current" select="$current_mod"/>
70 </xsl:apply-templates>
71 </select>
72 </xsl:template>
73
74 <xsl:template match="metadataSet" mode="meta-to-combo">
75 <xsl:param name="current"/>
76
77 <xsl:apply-templates mode="meta-to-combo">
78 <xsl:with-param name="set" select="@name"/>
79 <xsl:with-param name="current" select="$current"/>
80 </xsl:apply-templates>
81 </xsl:template>
82
83 <xsl:template match="metadata" mode="meta-to-combo">
84 <xsl:param name="set"/>
85 <xsl:param name="current"/>
86
87 <xsl:variable name="meta"><xsl:value-of select="$set"/>.<xsl:value-of select="@name"/></xsl:variable>
88
89 <!-- if this is the current value, then set combo box to this value -->
90 <xsl:choose>
91 <xsl:when test="$current = $meta">
92 <option value ="{$meta}" selected="{$meta}"><xsl:value-of select="$meta"/></option>
93 </xsl:when>
94 <xsl:otherwise>
95 <option value ="{$meta}"><xsl:value-of select="$meta"/></option>
96 </xsl:otherwise>
97 </xsl:choose>
98 </xsl:template>
99
100 <xsl:template match="*" mode="meta-to-combo">
101 <xsl:param name="current"/>
102 <xsl:apply-templates mode="meta-to-combo">
103 <xsl:with-param name="current" select="$current"/>
104 </xsl:apply-templates>
105 </xsl:template>
106
107
108 <!-- **************************************************************************** -->
109
110 <!-- **************************************************************************** -->
111 <!-- GSF STATEMENTS -->
112 <!-- **************************************************************************** -->
113
114
115 <!-- ********** GSF:CHOOSE-METADATA ********** -->
116 <xsl:template match="gsf:choose-metadata" mode="xml-to-gui">
117 <xsl:param name="depth"/>
118 <xsl:param name="metadataSets"/>
119
120 <div class="gsf_choose-metadata css_gsf_choose-metadata block" title="gsf:choose-metadata">
121 CHOOSE <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
122 <xsl:apply-templates mode="xml-to-gui">
123 <xsl:with-param name="depth" select="$depth"/>
124 <xsl:with-param name="metadataSets" select="$metadataSets"/>
125 </xsl:apply-templates>
126 END CHOOSE
127 </div>
128 </xsl:template>
129
130
131 <!-- ********** GSF:METADATA ********** -->
132 <xsl:template match="gsf:metadata" mode="xml-to-gui">
133 <xsl:param name="depth"/>
134 <xsl:param name="metadataSets"/>
135
136 <xsl:variable name="one">
137 <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata">METADATA <xsl:call-template name="meta-to-combo">
138 <xsl:with-param name="metadataSets" select="$metadataSets"/>
139 <xsl:with-param name="current" select="@name"/>
140 </xsl:call-template> <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
141 </div>
142 </xsl:variable>
143
144
145 <xsl:variable name="meta">
146 <xsl:call-template name="xml-to-string">
147 <xsl:with-param name="node-set" select="exsl:node-set($one)"/>
148 </xsl:call-template>
149 </xsl:variable>
150
151 <xsl:copy-of select="$one"/>
152
153 <br/>
154 <script type="text/javascript">
155 gsf_metadata_element = <xsl:text disable-output-escaping="yes">'</xsl:text><xsl:copy-of select="$one" disable-output-escaping="yes"/><xsl:text disable-output-escaping="yes">';</xsl:text>
156
157 </script>
158
159 </xsl:template>
160
161
162 <!-- ********** GSF:LINK ********** -->
163 <xsl:template match="gsf:link" mode="xml-to-gui">
164 <xsl:param name="depth"/>
165 <xsl:param name="metadataSets"/>
166
167 <div class="gsf_link css_gsf_link block" title="gsf:link">
168 LINK[type=
169 <select>
170 <xsl:choose>
171 <xsl:when test="@type='document'">
172 <option value = "document" selected = "document">Document</option>
173 <option value = "classifier">Classifier</option>
174 <option value = "source">Source</option>
175 </xsl:when>
176 <xsl:when test="@type='classifier'">
177 <option value = "classifier" selected = "classifier">Classifier</option>
178 <option value = "document">Document</option>
179 <option value = "source">Source</option>
180 </xsl:when>
181 <xsl:when test="@type='source'">
182 <option value = "source" selected = "source">Source</option>
183 <option value ="document">Document</option>
184 <option value ="classifier">Classifier</option>
185 </xsl:when>
186 <xsl:when test="@type='horizontal'">
187 <option value = "horizontal" selected = "horizontal">Horizontal</option>
188 <option value = "source" selected = "source">Source</option>
189 <option value ="document">Document</option>
190 <option value ="classifier">Classifier</option>
191 </xsl:when>
192 </xsl:choose>
193 </select>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
194 <xsl:apply-templates mode="xml-to-gui">
195 <xsl:with-param name="depth" select="$depth"/>
196 <xsl:with-param name="metadataSets" select="$metadataSets"/>
197 </xsl:apply-templates>
198 END LINK <br/>
199 </div>
200 </xsl:template>
201
202
203 <!-- ********** GSF:TEMPLATE ********** -->
204 <xsl:template match="gsf:template" mode="xml-to-gui">
205 <xsl:param name="depth"/>
206 <xsl:param name="metadataSets"/>
207
208 <!-- CHILD = <xsl:value-of select="child[1]/@name"/> -->
209 <!-- CHILD = <xsl:value-of select="child::*[name()][1]"/> -->
210
211
212 <!-- <xsl:for-each select="child::*"> -->
213 <!-- <xsl:value-of select="name()"/> -->
214 <!-- </xsl:for-each> -->
215
216
217 <div class="gsf_template block" title="gsf:template">
218 TEMPLATE[match=<xsl:value-of select="@match"/>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
219 <table border="1">
220 <tr class="tr">
221 <xsl:apply-templates mode="xml-to-gui">
222 <xsl:with-param name="depth" select="$depth"/>
223 <xsl:with-param name="metadataSets" select="$metadataSets"/>
224 </xsl:apply-templates>
225 </tr>
226 </table>
227 END TEMPLATE <br/>
228 </div>
229 </xsl:template>
230
231 <!-- ********** GSF:SWITCH ********** -->
232 <xsl:template match="gsf:switch" mode="xml-to-gui">
233 <xsl:param name="depth"/>
234 <xsl:param name="metadataSets"/>
235
236 <div class="gsf_switch block" title="gsf:switch">
237 SWITCH <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
238 <xsl:apply-templates mode="xml-to-gui">
239 <xsl:with-param name="depth" select="$depth"/>
240 <xsl:with-param name="metadataSets" select="$metadataSets"/>
241 </xsl:apply-templates>
242 END SWITCH
243 </div>
244 </xsl:template>
245
246
247 <!-- ********** GSF:WHEN ********** -->
248 <xsl:template match="gsf:when" mode="xml-to-gui">
249 <xsl:param name="depth"/>
250 <xsl:param name="metadataSets"/>
251
252 <div class="gsf_when block" title="gsf:when">
253 WHEN[test=<xsl:value-of select="@test"/>] <br/><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
254 <xsl:apply-templates mode="xml-to-gui">
255 <xsl:with-param name="depth" select="$depth"/>
256 <xsl:with-param name="metadataSets" select="$metadataSets"/>
257 </xsl:apply-templates>
258 END WHEN
259 </div>
260 </xsl:template>
261
262
263 <!-- ********** GSF:OTHERWISE ********** -->
264 <xsl:template match="gsf:otherwise" mode="xml-to-gui">
265 <xsl:param name="depth"/>
266 <xsl:param name="metadataSets"/>
267
268 <div class="gsf_otherwise block" title="gsf:otherwise">
269 OTHERWISE <br/><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
270 <xsl:apply-templates mode="xml-to-gui">
271 <xsl:with-param name="depth" select="$depth"/>
272 <xsl:with-param name="metadataSets" select="$metadataSets"/>
273 </xsl:apply-templates>
274 END OTHERWISE
275 </div>
276 </xsl:template>
277
278
279 <!-- ********** GSF:ICON ********** -->
280 <xsl:template match="gsf:icon" mode="xml-to-gui">
281 <xsl:param name="depth"/>
282 <xsl:param name="metadataSets"/>
283
284 <div class="gsf_icon block leaf" title="gsf:icon">
285 ICON[type=
286 <select>
287 <xsl:choose>
288 <xsl:when test="@type='document'">
289 <option value = "document" selected = "document">Document</option>
290 <option value = "classifier">Classifier</option>
291 <option value = "source">Source</option>
292 </xsl:when>
293 <xsl:when test="@type='classifier'">
294 <option value = "classifier" selected = "classifier">Classifier</option>
295 <option value = "document">Document</option>
296 <option value = "source">Source</option>
297 </xsl:when>
298 <xsl:when test="@type='source'">
299 <option value = "source" selected = "source">Source</option>
300 <option value ="document">Document</option>
301 <option value ="classifier">Classifier</option>
302 </xsl:when>
303 </xsl:choose>
304 </select>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
305 </div>
306 </xsl:template>
307
308
309 <!-- ********** GSF:DEFAULT ********** -->
310 <xsl:template match="gsf:default" mode="xml-to-gui">
311 <xsl:param name="depth"/>
312 <xsl:param name="metadataSets"/>
313
314 <div class="block" title="gsf:default">
315 DEFAULT <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
316 <xsl:apply-templates mode="xml-to-gui">
317 <xsl:with-param name="depth" select="$depth"/>
318 <xsl:with-param name="metadataSets" select="$metadataSets"/>
319 </xsl:apply-templates>
320 END DEFAULT
321 </div>
322 </xsl:template>
323
324
325 <!-- ********** TEXT ********** -->
326 <xsl:template match="text()" mode="xml-to-gui">
327 <xsl:param name="depth"/>
328 <xsl:param name="metadataSets"/>
329
330 <div class="block leaf" title="gsf:text">
331 TEXT <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
332 <xsl:variable name="rawtext"><xsl:value-of select="."/></xsl:variable>
333 TEXT = <input type="text" name="rawtextinput" size="10" value="{$rawtext}"/><br/>
334 </div>
335 </xsl:template>
336
337
338 <!-- ********** TABLE ********** -->
339 <xsl:template match="td" mode="xml-to-gui">
340 <xsl:param name="depth"/>
341 <xsl:param name="metadataSets"/>
342
343
344 <!-- <td class="td block resizable" title="td" valign="{@valign}" style='overflow: hidden;'> -->
345 <td valign="{@valign}" title="td">
346 <div class="td block" title="td-div">
347 <!-- <xsl:text>&lt;td</xsl:text>valign=<xsl:value-of select="@valign"/><xsl:text>&gt;</xsl:text><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a> -->
348 <xsl:apply-templates mode="xml-to-gui">
349 <xsl:with-param name="depth" select="$depth"/>
350 <xsl:with-param name="metadataSets" select="$metadataSets"/>
351 </xsl:apply-templates>
352 <!-- <xsl:text>&lt;/td&gt;</xsl:text><br/><br/> -->
353 </div>
354 </td>
355 </xsl:template>
356
357
358 <!-- ********** BREAK ********** -->
359 <xsl:template match="br" mode="xml-to-gui">
360 <xsl:param name="depth"/>
361 <xsl:param name="metadataSets"/>
362
363 <xsl:text>&lt;br/&gt;</xsl:text> <br/>
364
365 <xsl:apply-templates mode="xml-to-gui">
366 <xsl:with-param name="depth" select="$depth"/>
367 <xsl:with-param name="metadataSets" select="$metadataSets"/>
368 </xsl:apply-templates>
369 </xsl:template>
370
371
372 <!-- ********** MATCH ALL ********** -->
373 <xsl:template match="*" mode="xml-to-gui">
374 <xsl:param name="depth"/>
375 <xsl:param name="metadataSets"/>
376
377 <xsl:apply-templates mode="xml-to-gui">
378 <xsl:with-param name="depth" select="$depth"/>
379 <xsl:with-param name="metadataSets" select="$metadataSets"/>
380 </xsl:apply-templates>
381 </xsl:template>
382
383</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.