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

Last change on this file since 23336 was 23336, checked in by sjb48, 11 years ago

Continued work on XHTML parsing for format statement saving. Found js code for ensuring XHTML (innerXHTML). Removed a few unneccessary bits of code from default servlet that were lingering around from when we first started playing with format statements.

File size: 20.4 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>
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&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>
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"><xsl:text></xsl:text></input></xsl:when>
239 <xsl:otherwise>MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="{@mode}"/></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}"/></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>
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 <div class="block leaf gsf_text" title="gsf:text">
357 <xsl:variable name="rawtext"><xsl:value-of select="."/></xsl:variable>
358 <table class="header"><tbody><tr><td class="header"><input type="text" name="rawtextinput" size="10" value="{$rawtext}"></input></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
359 </div>
360 </xsl:template>
361
362
363 <!-- ********** TABLE ********** -->
364 <xsl:template match="td" mode="xml-to-gui">
365 <xsl:param name="depth"/>
366 <xsl:param name="metadataSets"/>
367
368
369 <!-- <td class="td block resizable" title="td" valign="{@valign}" style='overflow: hidden;'> -->
370 <td class="column" valign="{@valign}" title="td">
371 <div class="td-div block" title="td-div">
372 <div class="neverempty block" style="height:50px">NEVER EMPTY</div>
373
374 <!-- <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> -->
375 <xsl:apply-templates mode="xml-to-gui">
376 <xsl:with-param name="depth" select="$depth"/>
377 <xsl:with-param name="metadataSets" select="$metadataSets"/>
378 </xsl:apply-templates>
379 <!-- <xsl:text>&lt;/td&gt;</xsl:text><br/><br/> -->
380 </div>
381 </td>
382 <td class="droppable" width="10px" title="Drag a new column on to me"/>
383 </xsl:template>
384
385
386 <!-- ********** BREAK ********** -->
387 <xsl:template match="br" mode="xml-to-gui">
388 <xsl:param name="depth"/>
389 <xsl:param name="metadataSets"/>
390
391 <!-- <xsl:text>&lt;br/&gt;</xsl:text> <br/> -->
392
393 <xsl:apply-templates mode="xml-to-gui">
394 <xsl:with-param name="depth" select="$depth"/>
395 <xsl:with-param name="metadataSets" select="$metadataSets"/>
396 </xsl:apply-templates>
397 </xsl:template>
398
399
400 <!-- ********** MATCH ALL ********** -->
401 <xsl:template match="*" mode="xml-to-gui">
402 <xsl:param name="depth"/>
403 <xsl:param name="metadataSets"/>
404
405 <xsl:apply-templates mode="xml-to-gui">
406 <xsl:with-param name="depth" select="$depth"/>
407 <xsl:with-param name="metadataSets" select="$metadataSets"/>
408 </xsl:apply-templates>
409 </xsl:template>
410
411</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.