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

Last change on this file since 24243 was 24243, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

File size: 22.2 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:when test="$current!=''">ex.<xsl:value-of select="$current"/></xsl:when>
62 <xsl:otherwise>ex.Title</xsl:otherwise>
63 </xsl:choose>
64 </xsl:variable>
65
66 <xsl:variable name="exists">
67 <xsl:apply-templates select="$metadataSets" mode="search-meta-to-combo">
68 <xsl:with-param name="current" select="$current_mod"/> <!--<xsl:copy-of select="$current_mod"/></xsl:with-param> -->
69 </xsl:apply-templates>
70 </xsl:variable>
71
72 <xsl:choose>
73 <xsl:when test="$exists='TRUE'">
74 <select name="meta_select" onChange="onSelectChange(this)">
75 <xsl:apply-templates select="$metadataSets" mode="meta-to-combo">
76 <xsl:with-param name="current" select="$current_mod"/>
77 </xsl:apply-templates>
78 </select>
79 </xsl:when>
80 <xsl:otherwise>
81 <xsl:value-of select="$current_mod"/>
82 </xsl:otherwise>
83 </xsl:choose>
84
85 </xsl:template>
86
87 <xsl:template match="metadataSet" mode="search-meta-to-combo">
88 <xsl:param name="current"/>
89
90 <xsl:variable name="set"><xsl:value-of select="substring-before($current, '.')"/></xsl:variable>
91
92 <xsl:if test="@name=$set">
93 <xsl:apply-templates select="metadata" mode="search-meta-to-combo">
94 <!-- <xsl:with-param name="set" select="@name"/> --> <!-- name of the set -->
95 <xsl:with-param name="current" select="$current"/>
96 </xsl:apply-templates>
97 </xsl:if>
98 </xsl:template>
99
100 <xsl:template match="metadata" mode="search-meta-to-combo">
101 <xsl:param name="current"/>
102 <xsl:variable name="cur"><xsl:value-of select="substring-after($current, '.')"/></xsl:variable>
103 <xsl:if test="@name=$cur">TRUE</xsl:if>
104 </xsl:template>
105
106 <xsl:template match="*" mode="search-meta-to-combo">
107 <xsl:param name="current"/>
108 <xsl:apply-templates mode="search-meta-to-combo">
109 <xsl:with-param name="current" select="$current"/>
110 </xsl:apply-templates>
111 </xsl:template>
112
113 <xsl:template match="metadataSet" mode="meta-to-combo">
114 <xsl:param name="current"/>
115
116 <xsl:apply-templates mode="meta-to-combo">
117 <xsl:with-param name="set" select="@name"/> <!-- name of the set -->
118 <xsl:with-param name="current" select="$current"/>
119 </xsl:apply-templates>
120 </xsl:template>
121
122 <xsl:template match="metadata" mode="meta-to-combo">
123 <xsl:param name="set"/>
124 <xsl:param name="current"/>
125
126 <xsl:variable name="meta"><xsl:value-of select="$set"/>.<xsl:value-of select="@name"/></xsl:variable>
127
128 <xsl:choose>
129 <xsl:when test="$current = $meta">
130 <xsl:text disable-output-escaping="yes">&lt;option value="</xsl:text><xsl:value-of select="$meta"/><xsl:text disable-output-escaping="yes">" selected="selected"&gt;</xsl:text><xsl:value-of select="$meta"/><xsl:text disable-output-escaping="yes">&lt;/option&gt;</xsl:text>
131 <!-- <option value ="{$meta}" selected="selected"><xsl:value-of select="$meta"/></option> -->
132 </xsl:when>
133 <xsl:otherwise>
134 <option value ="{$meta}"><xsl:value-of select="$meta"/></option>
135 </xsl:otherwise>
136 </xsl:choose>
137 </xsl:template>
138
139 <xsl:template match="*" mode="meta-to-combo">
140 <xsl:param name="current"/>
141 <xsl:apply-templates mode="meta-to-combo">
142 <xsl:with-param name="current" select="$current"/>
143 </xsl:apply-templates>
144 </xsl:template>
145
146
147 <!-- **************************************************************************** -->
148
149 <!-- **************************************************************************** -->
150 <!-- GSF STATEMENTS -->
151 <!-- **************************************************************************** -->
152
153
154 <!-- ********** GSF:CHOOSE-METADATA ********** -->
155 <xsl:template match="gsf:choose-metadata" mode="xml-to-gui">
156 <xsl:param name="depth"/>
157 <xsl:param name="metadataSets"/>
158
159 <div class="gsf_choose_metadata css_gsf_choose_metadata block" title="gsf:choose-metadata">
160 <table class="header"><tbody><tr><td class="header">CHOOSE</td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick" title="Click me to expand">[-]</a></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
161 <xsl:apply-templates mode="xml-to-gui">
162 <xsl:with-param name="depth" select="$depth"/>
163 <xsl:with-param name="metadataSets" select="$metadataSets"/>
164 </xsl:apply-templates>
165 </div>
166 </xsl:template>
167
168
169 <!-- ********** GSF:METADATA ********** -->
170 <xsl:template match="gsf:metadata" mode="xml-to-gui">
171 <xsl:param name="depth"/>
172 <xsl:param name="metadataSets"/>
173
174 <!-- DEBUG metadata: <xsl:value-of select="@name"/>eol -->
175
176 <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata">
177 <xsl:variable name="combo">
178 <xsl:call-template name="meta-to-combo">
179 <xsl:with-param name="metadataSets" select="$metadataSets"/>
180 <xsl:with-param name="current" select="@name"/>
181 </xsl:call-template>
182 </xsl:variable>
183 <table class="header"><tbody><tr><td class="header"><xsl:copy-of select="$combo"/></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
184 </div>
185 </xsl:template>
186
187
188 <!-- ********** GSF:LINK ********** -->
189 <xsl:template match="gsf:link" mode="xml-to-gui">
190 <xsl:param name="depth"/>
191 <xsl:param name="metadataSets"/>
192
193 <div class="gsf_link css_gsf_link block" title="gsf:link">
194 <xsl:variable name="link">
195 LINK<select name="link_select" onChange="onSelectChange(this)">
196 <xsl:choose>
197 <xsl:when test="@type='document'">
198 <option value = "document" selected = "selected">Document</option>
199 <option value = "classifier">Classifier</option>
200 <option value = "source">Source</option>
201 </xsl:when>
202 <xsl:when test="@type='classifier'">
203 <option value = "classifier" selected = "selected">Classifier</option>
204 <option value = "document">Document</option>
205 <option value = "source">Source</option>
206 </xsl:when>
207 <xsl:when test="@type='source'">
208 <option value = "source" selected = "selected">Source</option>
209 <option value ="document">Document</option>
210 <option value ="classifier">Classifier</option>
211 </xsl:when>
212 <xsl:when test="@type='horizontal'">
213 <option value = "horizontal" selected = "selected">Horizontal</option>
214 <option value = "source">Source</option>
215 <option value ="document">Document</option>
216 <option value ="classifier">Classifier</option>
217 </xsl:when>
218 </xsl:choose>
219 </select>
220 </xsl:variable>
221 <table class="header"><tbody><tr><td class="header"><xsl:copy-of select="$link"/></td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick" title="Click me to expand">[-]</a></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
222 <xsl:apply-templates mode="xml-to-gui">
223 <xsl:with-param name="depth" select="$depth"/>
224 <xsl:with-param name="metadataSets" select="$metadataSets"/>
225 </xsl:apply-templates>
226 </div>
227 </xsl:template>
228
229
230 <!-- ********** GSF:TEMPLATE ********** -->
231 <xsl:template match="gsf:template" mode="xml-to-gui">
232 <xsl:param name="depth"/>
233 <xsl:param name="metadataSets"/>
234
235 <div class="gsf_template css_gsf_template block" title="gsf:template">
236 <xsl:variable name="mode">
237 <xsl:choose>
238 <xsl:when test="not(@mode)">MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="vertical" onChange="onTextChange(this, this.value)"><xsl:text></xsl:text></input></xsl:when>
239 <xsl:otherwise>MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="{@mode}" onChange="onTextChange(this, this.value)"/></xsl:otherwise>
240 </xsl:choose>
241 </xsl:variable>
242
243 <table class="header"><tbody><tr><td class="header">MATCH=<input class="match" type="text" name="rawtextinput" size="10" value="{@match}" onChange="onTextChange(this, this.value)"/></td><td class="header"><xsl:copy-of select="$mode"/></td><td class="header"><a href="#" class="minmax ui-icon ui-icon-plusthick" title="Click me to expand">[+]</a></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
244
245 <table class="table" border="1">
246 <tbody>
247 <tr class="tr">
248 <td class="droppable" width="10px"></td>
249 <xsl:apply-templates mode="xml-to-gui">
250 <xsl:with-param name="depth" select="$depth"/>
251 <xsl:with-param name="metadataSets" select="$metadataSets"/>
252 </xsl:apply-templates>
253 </tr>
254 </tbody>
255 </table>
256 </div>
257 </xsl:template>
258
259 <!-- ********** GSF:SWITCH ********** -->
260 <xsl:template match="gsf:switch" mode="xml-to-gui">
261 <xsl:param name="depth"/>
262 <xsl:param name="metadataSets"/>
263
264 <div class="gsf_switch css_gsf_switch block" title="gsf:switch">
265 <table class="header"><tbody><tr><td class="header">SWITCH</td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
266 <xsl:apply-templates mode="xml-to-gui">
267 <xsl:with-param name="depth" select="$depth"/>
268 <xsl:with-param name="metadataSets" select="$metadataSets"/>
269 </xsl:apply-templates>
270 </div>
271 </xsl:template>
272
273
274 <!-- ********** GSF:WHEN ********** -->
275 <xsl:template match="gsf:when" mode="xml-to-gui">
276 <xsl:param name="depth"/>
277 <xsl:param name="metadataSets"/>
278
279 <div class="gsf_when css_gsf_when block" title="gsf:when">
280 <table class="header"><tbody><tr><td class="header">WHEN<xsl:value-of select="@test"/></td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
281 <xsl:apply-templates mode="xml-to-gui">
282 <xsl:with-param name="depth" select="$depth"/>
283 <xsl:with-param name="metadataSets" select="$metadataSets"/>
284 </xsl:apply-templates>
285 </div>
286 </xsl:template>
287
288
289 <!-- ********** GSF:OTHERWISE ********** -->
290 <xsl:template match="gsf:otherwise" mode="xml-to-gui">
291 <xsl:param name="depth"/>
292 <xsl:param name="metadataSets"/>
293
294 <div class="gsf_otherwise css_gsf_otherwise block" title="gsf:otherwise">
295 <table class="header"><tbody><tr><td class="header">OTHERWISE</td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td class="header"><a href="#" class="remove">[x]</a></td><td><a href="#" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
296 <xsl:apply-templates mode="xml-to-gui">
297 <xsl:with-param name="depth" select="$depth"/>
298 <xsl:with-param name="metadataSets" select="$metadataSets"/>
299 </xsl:apply-templates>
300 </div>
301 </xsl:template>
302
303
304 <!-- ********** GSF:ICON ********** -->
305 <xsl:template match="gsf:icon" mode="xml-to-gui">
306 <xsl:param name="depth"/>
307 <xsl:param name="metadataSets"/>
308
309 <div class="gsf_icon css_gsf_icon block leaf" title="gsf:icon">
310 <xsl:variable name="icon">
311 ICON<select name="icon_select" onChange="onSelectChange(this, this.value)">
312 <xsl:choose>
313 <xsl:when test="@type='document'">
314 <option value = "document" selected = "selected">Document</option>
315 <option value = "classifier">Classifier</option>
316 <option value = "source">Source</option>
317 </xsl:when>
318 <xsl:when test="@type='classifier'">
319 <option value = "classifier" selected = "selected">Classifier</option>
320 <option value = "document">Document</option>
321 <option value = "source">Source</option>
322 </xsl:when>
323 <xsl:when test="@type='source'">
324 <option value = "source" selected = "selected">Source</option>
325 <option value ="document">Document</option>
326 <option value ="classifier">Classifier</option>
327 </xsl:when>
328 </xsl:choose>
329 </select>
330 </xsl:variable>
331 <table class="header"><tbody><tr><td class="header"><xsl:copy-of select="$icon"/></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
332 </div>
333 </xsl:template>
334
335
336 <!-- ********** GSF:DEFAULT ********** -->
337 <xsl:template match="gsf:default" mode="xml-to-gui">
338 <xsl:param name="depth"/>
339 <xsl:param name="metadataSets"/>
340
341 <div class="block gsf_default" title="gsf:default">
342 <table class="header"><tbody><tr><td class="header">DEFAULT</td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick" title="Click me to expand">[-]</a></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
343 <xsl:apply-templates mode="xml-to-gui">
344 <xsl:with-param name="depth" select="$depth"/>
345 <xsl:with-param name="metadataSets" select="$metadataSets"/>
346 </xsl:apply-templates>
347 </div>
348 </xsl:template>
349
350
351 <!-- ********** TEXT ********** -->
352 <xsl:template match="text()" mode="xml-to-gui">
353 <xsl:param name="depth"/>
354 <xsl:param name="metadataSets"/>
355
356 <xsl:variable name="rawtext"><xsl:value-of select="."/></xsl:variable>
357
358 <xsl:if test="normalize-space($rawtext) != '' ">
359 <div class="block leaf gsf_text" title="gsf:text">
360 <table class="header">
361 <tbody>
362 <tr>
363 <td class="header">
364 <input class="text" type="text" name="rawtextinput" size="10" value="{$rawtext}" onChange="onTextChange(this, this.value)"></input>
365 </td>
366 <td class="header">
367 <a href="[myhref]" class="ui-icon ui-icon-closethick"/>
368 </td>
369 </tr>
370 </tbody>
371 </table>
372 </div>
373 </xsl:if>
374 </xsl:template>
375
376
377 <!-- ********** TABLE ********** -->
378 <xsl:template match="td" mode="xml-to-gui">
379 <xsl:param name="depth"/>
380 <xsl:param name="metadataSets"/>
381
382
383 <td class="column" valign="{@valign}" title="td">
384 <div class="td-div block" title="td-div">
385 <div class="neverempty block" style="height:50px">NEVER EMPTY</div>
386
387 <xsl:apply-templates mode="xml-to-gui">
388 <xsl:with-param name="depth" select="$depth"/>
389 <xsl:with-param name="metadataSets" select="$metadataSets"/>
390 </xsl:apply-templates>
391 </div>
392 </td>
393 <td class="droppable" width="10px" title="Drag a new column on to me"/>
394 </xsl:template>
395
396
397 <!-- ********** BREAK ********** -->
398 <xsl:template match="br" mode="xml-to-gui">
399 <xsl:param name="depth"/>
400 <xsl:param name="metadataSets"/>
401
402 <div class="block leaf gsf_text" title="gsf:text">
403 <table class="header"><tbody><tr><td class="header">&lt;<input class="text" type="text" name="rawtextinput" size="10" value="br/"></input>&gt;</td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
404 </div>
405
406 <xsl:apply-templates mode="xml-to-gui">
407 <xsl:with-param name="depth" select="$depth"/>
408 <xsl:with-param name="metadataSets" select="$metadataSets"/>
409 </xsl:apply-templates>
410 </xsl:template>
411
412 <!-- ********** Italics ********** -->
413 <xsl:template match="i" mode="xml-to-gui">
414 <xsl:param name="depth"/>
415 <xsl:param name="metadataSets"/>
416
417 <div class="block leaf gsf_text" title="gsf:text">
418 <table class="header"><tbody><tr><td class="header">&lt;<input class="text" type="text" name="rawtextinput" size="10" value="i"></input>&gt;</td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
419 </div>
420
421 <xsl:apply-templates mode="xml-to-gui">
422 <xsl:with-param name="depth" select="$depth"/>
423 <xsl:with-param name="metadataSets" select="$metadataSets"/>
424 </xsl:apply-templates>
425
426 <div class="block leaf gsf_text" title="gsf:text">
427 <xsl:variable name="rawtext"><xsl:text disable-output-escaping='no'>/i</xsl:text></xsl:variable>
428 <table class="header"><tbody><tr><td class="header">&lt;<input class="text" type="text" name="rawtextinput" size="10" value="{$rawtext}"></input>&gt;</td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
429 </div>
430
431 </xsl:template>
432
433 <!-- ********** MATCH ALL ********** -->
434 <xsl:template match="*" mode="xml-to-gui">
435 <xsl:param name="depth"/>
436 <xsl:param name="metadataSets"/>
437
438 <xsl:apply-templates mode="xml-to-gui">
439 <xsl:with-param name="depth" select="$depth"/>
440 <xsl:with-param name="metadataSets" select="$metadataSets"/>
441 </xsl:apply-templates>
442 </xsl:template>
443
444</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.