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

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

Working on establishing a nested sortable list for drag-and-drop functionality. Established a hierarchy based on gsf so each gsf element has its own list, then similar elements can be linked between.

File size: 16.3 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
24 <xsl:output omit-xml-declaration="yes"/>
25
26 <xsl:template name="xml-to-gui">
27 <xsl:param name="node-set" select="."/>
28 <xsl:param name="metadataSets" select="."/>
29
30 <xsl:value-of select="metadataSets[@name]"/>
31 <xsl:apply-templates select="$node-set" mode="xml-to-gui">
32 <xsl:with-param name="depth" select="1"/>
33 <xsl:with-param name="metadataSets" select="$metadataSets"/>
34 </xsl:apply-templates>
35 </xsl:template>
36
37 <xsl:template match="/" mode="xml-to-gui">
38 <xsl:param name="depth"/>
39 <xsl:param name="metadataSets"/>
40
41 <xsl:apply-templates mode="xml-to-gui">
42 <xsl:with-param name="depth" select="$depth"/>
43 <xsl:with-param name="metadataSets" select="$metadataSets"/>
44 </xsl:apply-templates>
45 </xsl:template>
46
47
48 <!-- **************************************************************************** -->
49 <!-- COMBO BOX CREATION -->
50 <!-- **************************************************************************** -->
51
52 <xsl:template name="meta-to-combo">
53 <xsl:param name="metadataSets" select='.'/>
54 <xsl:param name="current" select='.'/>
55
56 <xsl:variable name="current_mod">
57 <xsl:choose>
58 <xsl:when test="contains($current,'.')"><xsl:value-of select="$current"/></xsl:when>
59 <xsl:otherwise>ex.<xsl:value-of select="$current"/></xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
62
63 <select>
64 <option value ="{$current_mod}" disabled="disabled" selected="{$current_mod}"><xsl:value-of select="$current_mod"/></option>
65
66 <xsl:apply-templates select="$metadataSets" mode="meta-to-combo">
67 <xsl:with-param name="current" select="$current_mod"/>
68 </xsl:apply-templates>
69 </select>
70 </xsl:template>
71
72 <xsl:template match="metadataSet" mode="meta-to-combo">
73 <xsl:param name="current"/>
74
75 <xsl:apply-templates mode="meta-to-combo">
76 <xsl:with-param name="set" select="@name"/>
77 <xsl:with-param name="current" select="$current"/>
78 </xsl:apply-templates>
79 </xsl:template>
80
81 <xsl:template match="metadata" mode="meta-to-combo">
82 <xsl:param name="set"/>
83 <xsl:param name="current"/>
84
85 <xsl:variable name="meta"><xsl:value-of select="$set"/>.<xsl:value-of select="@name"/></xsl:variable>
86
87 <!-- if this is the current value, then set combo box to this value -->
88 <xsl:choose>
89 <xsl:when test="$current = $meta">
90 <option value ="{$meta}" selected="{$meta}"><xsl:value-of select="$meta"/></option>
91 </xsl:when>
92 <xsl:otherwise>
93 <option value ="{$meta}"><xsl:value-of select="$meta"/></option>
94 </xsl:otherwise>
95 </xsl:choose>
96 </xsl:template>
97
98 <xsl:template match="*" mode="meta-to-combo">
99 <xsl:param name="current"/>
100 <xsl:apply-templates mode="meta-to-combo">
101 <xsl:with-param name="current" select="$current"/>
102 </xsl:apply-templates>
103 </xsl:template>
104
105
106 <!-- **************************************************************************** -->
107
108
109 <!-- **************************************************************************** -->
110 <!-- GSF STATEMENTS -->
111 <!-- **************************************************************************** -->
112
113
114 <!-- ********** GSF:CHOOSE-METADATA ********** -->
115 <xsl:template match="gsf:choose-metadata" mode="xml-to-gui">
116 <xsl:param name="depth"/>
117 <xsl:param name="metadataSets"/>
118
119 <div class="gsf:choose-metadata block" title="gsf:choose-metadata" id="gsf:choose-metadata-{generate-id()}">
120 <!-- <div class="header"> -->
121 CHOOSE <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
122 <!--</div>-->
123 <!--<div class="content">-->
124 <xsl:apply-templates mode="xml-to-gui">
125 <xsl:with-param name="depth" select="$depth"/>
126 <xsl:with-param name="metadataSets" select="$metadataSets"/>
127 </xsl:apply-templates>
128 <!--</div>-->
129 <!--<div class="footer">-->
130 END CHOOSE
131 <!--</div>-->
132 </div>
133 </xsl:template>
134
135
136 <!-- ********** GSF:METADATA ********** -->
137 <xsl:template match="gsf:metadata" mode="xml-to-gui">
138 <xsl:param name="depth"/>
139 <xsl:param name="metadataSets"/>
140
141 <div class="gsf:metadata block leaf" title="gsf:metadata" id="gsf:metadata-{generate-id()}">
142 <!--<div class="header">-->
143 METADATA
144 <!--</div>-->
145 <!--<div class="content">-->
146 <xsl:call-template name="meta-to-combo">
147 <xsl:with-param name="metadataSets" select="$metadataSets"/>
148 <xsl:with-param name="current" select="@name"/>
149 </xsl:call-template>
150 <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
151 <!--</div>-->
152 </div>
153 </xsl:template>
154
155
156 <!-- ********** GSF:LINK ********** -->
157 <xsl:template match="gsf:link" mode="xml-to-gui">
158 <xsl:param name="depth"/>
159 <xsl:param name="metadataSets"/>
160
161 <div class="gsf:link block" title="gsf:link" id="gsf:link-{generate-id()}">
162 LINK[type=
163 <select>
164 <xsl:choose>
165 <xsl:when test="@type='document'">
166 <option value = "document" selected = "document">Document</option>
167 <option value = "classifier">Classifier</option>
168 <option value = "source">Source</option>
169 </xsl:when>
170 <xsl:when test="@type='classifier'">
171 <option value = "classifier" selected = "classifier">Classifier</option>
172 <option value = "document">Document</option>
173 <option value = "source">Source</option>
174 </xsl:when>
175 <xsl:when test="@type='source'">
176 <option value = "source" selected = "source">Source</option>
177 <option value ="document">Document</option>
178 <option value ="classifier">Classifier</option>
179 </xsl:when>
180 <xsl:when test="@type='horizontal'">
181 <option value = "horizontal" selected = "horizontal">Horizontal</option>
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:choose>
187 </select>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
188 <xsl:apply-templates mode="xml-to-gui">
189 <xsl:with-param name="depth" select="$depth"/>
190 <xsl:with-param name="metadataSets" select="$metadataSets"/>
191 </xsl:apply-templates>
192 END LINK <br/>
193 </div>
194 </xsl:template>
195
196
197 <!-- ********** GSF:TEMPLATE ********** -->
198 <xsl:template match="gsf:template" mode="xml-to-gui">
199 <xsl:param name="depth"/>
200 <xsl:param name="metadataSets"/>
201
202 <div class="gsf:template block" title="gsf:template" id="gsf:template-{generate-id()}">
203 TEMPLATE[match=<xsl:value-of select="@match"/>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
204 <xsl:apply-templates mode="xml-to-gui">
205 <xsl:with-param name="depth" select="$depth"/>
206 <xsl:with-param name="metadataSets" select="$metadataSets"/>
207 </xsl:apply-templates>
208 END TEMPLATE <br/>
209 </div>
210 </xsl:template>
211
212 <!-- ********** GSF:SWITCH ********** -->
213 <xsl:template match="gsf:switch" mode="xml-to-gui">
214 <xsl:param name="depth"/>
215 <xsl:param name="metadataSets"/>
216
217 <div class="gsf:switch block" title="gsf:switch" id="gsf:switch-{generate-id()}">
218 SWITCH <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
219 <xsl:apply-templates mode="xml-to-gui">
220 <xsl:with-param name="depth" select="$depth"/>
221 <xsl:with-param name="metadataSets" select="$metadataSets"/>
222 </xsl:apply-templates>
223 END SWITCH
224 </div>
225 </xsl:template>
226
227
228 <!-- ********** GSF:WHEN ********** -->
229 <xsl:template match="gsf:when" mode="xml-to-gui">
230 <xsl:param name="depth"/>
231 <xsl:param name="metadataSets"/>
232
233 <div class="gsf:when block" title="gsf:when" id="gsf:when-{generate-id()}">
234 WHEN[test=<xsl:value-of select="@test"/>] <br/><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
235 <xsl:apply-templates mode="xml-to-gui">
236 <xsl:with-param name="depth" select="$depth"/>
237 <xsl:with-param name="metadataSets" select="$metadataSets"/>
238 </xsl:apply-templates>
239 END WHEN
240 </div>
241 </xsl:template>
242
243
244 <!-- ********** GSF:OTHERWISE ********** -->
245 <xsl:template match="gsf:otherwise" mode="xml-to-gui">
246 <xsl:param name="depth"/>
247 <xsl:param name="metadataSets"/>
248
249 <div class="gsf:otherwise block" title="gsf:otherwise" id="gsf:otherwise-{generate-id()}">
250 OTHERWISE <br/><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
251 <xsl:apply-templates mode="xml-to-gui">
252 <xsl:with-param name="depth" select="$depth"/>
253 <xsl:with-param name="metadataSets" select="$metadataSets"/>
254 </xsl:apply-templates>
255 END OTHERWISE
256 </div>
257 </xsl:template>
258
259
260 <!-- ********** GSF:ICON ********** -->
261 <xsl:template match="gsf:icon" mode="xml-to-gui">
262 <xsl:param name="depth"/>
263 <xsl:param name="metadataSets"/>
264
265 <div class="gsf:icon block leaf" title="gsf:icon" id="gsf:icon-{generate-id()}">
266 ICON[type=
267 <select>
268 <xsl:choose>
269 <xsl:when test="@type='document'">
270 <option value = "document" selected = "document">Document</option>
271 <option value = "classifier">Classifier</option>
272 <option value = "source">Source</option>
273 </xsl:when>
274 <xsl:when test="@type='classifier'">
275 <option value = "classifier" selected = "classifier">Classifier</option>
276 <option value = "document">Document</option>
277 <option value = "source">Source</option>
278 </xsl:when>
279 <xsl:when test="@type='source'">
280 <option value = "source" selected = "source">Source</option>
281 <option value ="document">Document</option>
282 <option value ="classifier">Classifier</option>
283 </xsl:when>
284 </xsl:choose>
285 </select>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
286 </div>
287 </xsl:template>
288
289
290 <!-- ********** GSF:DEFAULT ********** -->
291 <xsl:template match="gsf:default" mode="xml-to-gui">
292 <xsl:param name="depth"/>
293 <xsl:param name="metadataSets"/>
294
295 <div class="block" title="gsf:default" id="gsf:default-{generate-id()}">
296 <div class="header">
297 DEFAULT <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
298 </div>
299 <div class="content">
300 <xsl:apply-templates mode="xml-to-gui">
301 <xsl:with-param name="depth" select="$depth"/>
302 <xsl:with-param name="metadataSets" select="$metadataSets"/>
303 </xsl:apply-templates>
304 </div>
305 <div class="footer">
306 END DEFAULT
307 </div>
308 </div>
309 </xsl:template>
310
311
312 <!-- ********** TEXT ********** -->
313 <xsl:template match="text()" mode="xml-to-gui">
314 <xsl:param name="depth"/>
315 <xsl:param name="metadataSets"/>
316
317 <div class="block leaf" title="gsf:text" id="gsf:text-{generate-id()}">
318 TEXT <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
319 <xsl:variable name="rawtext"><xsl:value-of select="."/></xsl:variable>
320 TEXT = <input type="text" name="rawtextinput" size="10" value="{$rawtext}"/><br/>
321 </div>
322 </xsl:template>
323
324
325 <!-- ********** TABLE ********** -->
326 <xsl:template match="td" mode="xml-to-gui">
327 <xsl:param name="depth"/>
328 <xsl:param name="metadataSets"/>
329
330 <div class="table block" title="gsf:table" id="gsf:table-{generate-id()}">
331 <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>
332 <xsl:apply-templates mode="xml-to-gui">
333 <xsl:with-param name="depth" select="$depth"/>
334 <xsl:with-param name="metadataSets" select="$metadataSets"/>
335 </xsl:apply-templates>
336 <xsl:text>&lt;/td&gt;</xsl:text><br/><br/>
337 </div>
338 </xsl:template>
339
340
341 <!-- ********** BREAK ********** -->
342 <xsl:template match="br" mode="xml-to-gui">
343 <xsl:param name="depth"/>
344 <xsl:param name="metadataSets"/>
345
346 <xsl:text>&lt;br/&gt;</xsl:text> <br/>
347
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:template>
353
354
355 <!-- ********** MATCH ALL ********** -->
356 <xsl:template match="*" mode="xml-to-gui">
357 <xsl:param name="depth"/>
358 <xsl:param name="metadataSets"/>
359
360 <xsl:apply-templates mode="xml-to-gui">
361 <xsl:with-param name="depth" select="$depth"/>
362 <xsl:with-param name="metadataSets" select="$metadataSets"/>
363 </xsl:apply-templates>
364 </xsl:template>
365
366</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.