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

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

Working on auto-resizing tables and column insertion. Partially working.

File size: 16.5 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 </div>
127 </xsl:template>
128
129
130 <!-- ********** GSF:METADATA ********** -->
131 <xsl:template match="gsf:metadata" mode="xml-to-gui">
132 <xsl:param name="depth"/>
133 <xsl:param name="metadataSets"/>
134
135 <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata"><xsl:call-template name="meta-to-combo">
136 <xsl:with-param name="metadataSets" select="$metadataSets"/>
137 <xsl:with-param name="current" select="@name"/>
138 </xsl:call-template><a href="#" class="remove">[x]</a>
139 </div>
140 </xsl:template>
141
142
143 <!-- ********** GSF:LINK ********** -->
144 <xsl:template match="gsf:link" mode="xml-to-gui">
145 <xsl:param name="depth"/>
146 <xsl:param name="metadataSets"/>
147
148 <div class="gsf_link css_gsf_link block" title="gsf:link">
149 LINK[type=
150 <select>
151 <xsl:choose>
152 <xsl:when test="@type='document'">
153 <option value = "document" selected = "document">Document</option>
154 <option value = "classifier">Classifier</option>
155 <option value = "source">Source</option>
156 </xsl:when>
157 <xsl:when test="@type='classifier'">
158 <option value = "classifier" selected = "classifier">Classifier</option>
159 <option value = "document">Document</option>
160 <option value = "source">Source</option>
161 </xsl:when>
162 <xsl:when test="@type='source'">
163 <option value = "source" selected = "source">Source</option>
164 <option value ="document">Document</option>
165 <option value ="classifier">Classifier</option>
166 </xsl:when>
167 <xsl:when test="@type='horizontal'">
168 <option value = "horizontal" selected = "horizontal">Horizontal</option>
169 <option value = "source" selected = "source">Source</option>
170 <option value ="document">Document</option>
171 <option value ="classifier">Classifier</option>
172 </xsl:when>
173 </xsl:choose>
174 </select>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
175 <xsl:apply-templates mode="xml-to-gui">
176 <xsl:with-param name="depth" select="$depth"/>
177 <xsl:with-param name="metadataSets" select="$metadataSets"/>
178 </xsl:apply-templates>
179 </div>
180 </xsl:template>
181
182
183 <!-- ********** GSF:TEMPLATE ********** -->
184 <xsl:template match="gsf:template" mode="xml-to-gui">
185 <xsl:param name="depth"/>
186 <xsl:param name="metadataSets"/>
187
188 <!-- CHILD = <xsl:value-of select="child[1]/@name"/> -->
189 <!-- CHILD = <xsl:value-of select="child::*[name()][1]"/> -->
190
191
192 <!-- <xsl:for-each select="child::*"> -->
193 <!-- <xsl:value-of select="name()"/> -->
194 <!-- </xsl:for-each> -->
195
196
197 <div class="gsf_template css_gsf_template block" title="gsf:template">
198 MATCH=<input type="text" name="rawtextinput" size="10" value="{@match}"/><xsl:choose>
199 <xsl:when test="not(@mode)"> <!-- parameter has not been supplied -->
200 </xsl:when>
201 <xsl:otherwise>MODE=<input type="text" name="rawtextinput" size="10" value="{@mode}"/></xsl:otherwise>
202 </xsl:choose><a href="#" class="minmax">[+]</a><a href="#" class="remove">[x]</a>
203 <table class="table" border="1">
204 <tbody>
205 <tr class="tr">
206 <td class="droppable" width="10px"/>
207 <xsl:apply-templates mode="xml-to-gui">
208 <xsl:with-param name="depth" select="$depth"/>
209 <xsl:with-param name="metadataSets" select="$metadataSets"/>
210 </xsl:apply-templates>
211 </tr>
212 </tbody>
213 </table>
214 </div><br/>
215 </xsl:template>
216
217 <!-- ********** GSF:SWITCH ********** -->
218 <xsl:template match="gsf:switch" mode="xml-to-gui">
219 <xsl:param name="depth"/>
220 <xsl:param name="metadataSets"/>
221
222 <div class="gsf_switch css_gsf_switch block" title="gsf:switch">
223 SWITCH <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
224 <xsl:apply-templates mode="xml-to-gui">
225 <xsl:with-param name="depth" select="$depth"/>
226 <xsl:with-param name="metadataSets" select="$metadataSets"/>
227 </xsl:apply-templates>
228 </div>
229 </xsl:template>
230
231
232 <!-- ********** GSF:WHEN ********** -->
233 <xsl:template match="gsf:when" mode="xml-to-gui">
234 <xsl:param name="depth"/>
235 <xsl:param name="metadataSets"/>
236
237 <div class="gsf_when css_gsf_when block" title="gsf:when">
238 WHEN[test=<xsl:value-of select="@test"/>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
239 <xsl:apply-templates mode="xml-to-gui">
240 <xsl:with-param name="depth" select="$depth"/>
241 <xsl:with-param name="metadataSets" select="$metadataSets"/>
242 </xsl:apply-templates>
243 </div>
244 </xsl:template>
245
246
247 <!-- ********** GSF:OTHERWISE ********** -->
248 <xsl:template match="gsf:otherwise" mode="xml-to-gui">
249 <xsl:param name="depth"/>
250 <xsl:param name="metadataSets"/>
251
252 <div class="gsf_otherwise css_gsf_otherwise block" title="gsf:otherwise">
253 OTHERWISE <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 </div>
259 </xsl:template>
260
261
262 <!-- ********** GSF:ICON ********** -->
263 <xsl:template match="gsf:icon" mode="xml-to-gui">
264 <xsl:param name="depth"/>
265 <xsl:param name="metadataSets"/>
266
267 <div class="gsf_icon css_gsf_icon block leaf" title="gsf:icon">
268 ICON[type=
269 <select>
270 <xsl:choose>
271 <xsl:when test="@type='document'">
272 <option value = "document" selected = "document">Document</option>
273 <option value = "classifier">Classifier</option>
274 <option value = "source">Source</option>
275 </xsl:when>
276 <xsl:when test="@type='classifier'">
277 <option value = "classifier" selected = "classifier">Classifier</option>
278 <option value = "document">Document</option>
279 <option value = "source">Source</option>
280 </xsl:when>
281 <xsl:when test="@type='source'">
282 <option value = "source" selected = "source">Source</option>
283 <option value ="document">Document</option>
284 <option value ="classifier">Classifier</option>
285 </xsl:when>
286 </xsl:choose>
287 </select>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
288 </div>
289 </xsl:template>
290
291
292 <!-- ********** GSF:DEFAULT ********** -->
293 <xsl:template match="gsf:default" mode="xml-to-gui">
294 <xsl:param name="depth"/>
295 <xsl:param name="metadataSets"/>
296
297 <div class="block" title="gsf:default">
298 DEFAULT <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
299 <xsl:apply-templates mode="xml-to-gui">
300 <xsl:with-param name="depth" select="$depth"/>
301 <xsl:with-param name="metadataSets" select="$metadataSets"/>
302 </xsl:apply-templates>
303 </div>
304 </xsl:template>
305
306
307 <!-- ********** TEXT ********** -->
308 <xsl:template match="text()" mode="xml-to-gui">
309 <xsl:param name="depth"/>
310 <xsl:param name="metadataSets"/>
311
312 <div class="block leaf" title="gsf:text">
313 <xsl:variable name="rawtext"><xsl:value-of select="."/></xsl:variable>
314 TEXT = <input type="text" name="rawtextinput" size="10" value="{$rawtext}"/><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
315 </div>
316 </xsl:template>
317
318
319 <!-- ********** TABLE ********** -->
320 <xsl:template match="td" mode="xml-to-gui">
321 <xsl:param name="depth"/>
322 <xsl:param name="metadataSets"/>
323
324
325 <!-- <td class="td block resizable" title="td" valign="{@valign}" style='overflow: hidden;'> -->
326 <td valign="{@valign}" title="td">
327 <div class="td block" title="td-div">
328 <!-- <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> -->
329 <xsl:apply-templates mode="xml-to-gui">
330 <xsl:with-param name="depth" select="$depth"/>
331 <xsl:with-param name="metadataSets" select="$metadataSets"/>
332 </xsl:apply-templates>
333 <!-- <xsl:text>&lt;/td&gt;</xsl:text><br/><br/> -->
334 </div>
335 </td>
336 <td class="droppable" width="10px"/>
337 </xsl:template>
338
339
340 <!-- ********** BREAK ********** -->
341 <xsl:template match="br" mode="xml-to-gui">
342 <xsl:param name="depth"/>
343 <xsl:param name="metadataSets"/>
344
345 <xsl:text>&lt;br/&gt;</xsl:text> <br/>
346
347 <xsl:apply-templates mode="xml-to-gui">
348 <xsl:with-param name="depth" select="$depth"/>
349 <xsl:with-param name="metadataSets" select="$metadataSets"/>
350 </xsl:apply-templates>
351 </xsl:template>
352
353
354 <!-- ********** MATCH ALL ********** -->
355 <xsl:template match="*" mode="xml-to-gui">
356 <xsl:param name="depth"/>
357 <xsl:param name="metadataSets"/>
358
359 <xsl:apply-templates mode="xml-to-gui">
360 <xsl:with-param name="depth" select="$depth"/>
361 <xsl:with-param name="metadataSets" select="$metadataSets"/>
362 </xsl:apply-templates>
363 </xsl:template>
364
365</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.