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

Last change on this file since 22987 was 22987, checked in by sjb48, 14 years ago
File size: 19.2 KB
RevLine 
[22458]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"
[22473]21 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
[22569]22 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
23 xmlns:exsl="http://exslt.org/common"
24 extension-element-prefixes="exsl" >
[22458]25
[22473]26 <xsl:output omit-xml-declaration="yes"/>
[22458]27
[22473]28 <xsl:template name="xml-to-gui">
29 <xsl:param name="node-set" select="."/>
30 <xsl:param name="metadataSets" select="."/>
[22458]31
[22473]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>
[22458]38
[22473]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>
[22569]48 <!-- **************************************************************************** -->
[22458]49
[22516]50 <!-- **************************************************************************** -->
51 <!-- COMBO BOX CREATION -->
52 <!-- **************************************************************************** -->
[22458]53
[22473]54 <xsl:template name="meta-to-combo">
55 <xsl:param name="metadataSets" select='.'/>
56 <xsl:param name="current" select='.'/>
[22458]57
[22473]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
[22516]65 <select>
[22473]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"/>
[22516]86
[22473]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 -->
[22458]90 <xsl:choose>
[22473]91 <xsl:when test="$current = $meta">
[22516]92 <option value ="{$meta}" selected="{$meta}"><xsl:value-of select="$meta"/></option>
[22473]93 </xsl:when>
94 <xsl:otherwise>
[22516]95 <option value ="{$meta}"><xsl:value-of select="$meta"/></option>
[22473]96 </xsl:otherwise>
[22458]97 </xsl:choose>
[22473]98 </xsl:template>
[22458]99
[22473]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>
[22458]106
107
[22516]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"/>
[22569]119
[22598]120 <div class="gsf_choose_metadata css_gsf_choose_metadata block" title="gsf:choose-metadata">
[22987]121 <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>
[22516]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>
[22569]126 </div>
[22516]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
[22768]135 <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata">
136 <xsl:variable name="combo">
137 <xsl:call-template name="meta-to-combo">
[22569]138 <xsl:with-param name="metadataSets" select="$metadataSets"/>
139 <xsl:with-param name="current" select="@name"/>
[22768]140 </xsl:call-template>
141 </xsl:variable>
[22987]142 <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>
[22516]143 </div>
144 </xsl:template>
145
146
147 <!-- ********** GSF:LINK ********** -->
[22473]148 <xsl:template match="gsf:link" mode="xml-to-gui">
149 <xsl:param name="depth"/>
150 <xsl:param name="metadataSets"/>
[22569]151
152 <div class="gsf_link css_gsf_link block" title="gsf:link">
[22768]153 <xsl:variable name="link">
[22987]154 LINK<select>
[22473]155 <xsl:choose>
156 <xsl:when test="@type='document'">
157 <option value = "document" selected = "document">Document</option>
158 <option value = "classifier">Classifier</option>
159 <option value = "source">Source</option>
160 </xsl:when>
161 <xsl:when test="@type='classifier'">
162 <option value = "classifier" selected = "classifier">Classifier</option>
163 <option value = "document">Document</option>
164 <option value = "source">Source</option>
165 </xsl:when>
166 <xsl:when test="@type='source'">
167 <option value = "source" selected = "source">Source</option>
168 <option value ="document">Document</option>
169 <option value ="classifier">Classifier</option>
170 </xsl:when>
171 <xsl:when test="@type='horizontal'">
172 <option value = "horizontal" selected = "horizontal">Horizontal</option>
173 <option value = "source" selected = "source">Source</option>
174 <option value ="document">Document</option>
175 <option value ="classifier">Classifier</option>
176 </xsl:when>
177 </xsl:choose>
[22987]178 </select>
[22768]179 </xsl:variable>
[22987]180 <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>
[22473]181 <xsl:apply-templates mode="xml-to-gui">
182 <xsl:with-param name="depth" select="$depth"/>
183 <xsl:with-param name="metadataSets" select="$metadataSets"/>
184 </xsl:apply-templates>
185 </div>
186 </xsl:template>
[22458]187
[22516]188
189 <!-- ********** GSF:TEMPLATE ********** -->
[22473]190 <xsl:template match="gsf:template" mode="xml-to-gui">
191 <xsl:param name="depth"/>
192 <xsl:param name="metadataSets"/>
[22458]193
[22569]194 <!-- CHILD = <xsl:value-of select="child[1]/@name"/> -->
195 <!-- CHILD = <xsl:value-of select="child::*[name()][1]"/> -->
196
197
198 <!-- <xsl:for-each select="child::*"> -->
199 <!-- <xsl:value-of select="name()"/> -->
200 <!-- </xsl:for-each> -->
201
202
[22598]203 <div class="gsf_template css_gsf_template block" title="gsf:template">
[22768]204 <xsl:variable name="mode">
205 <xsl:choose>
[22676]206 <xsl:when test="not(@mode)"> <!-- parameter has not been supplied -->
207 </xsl:when>
208 <xsl:otherwise>MODE=<input type="text" name="rawtextinput" size="10" value="{@mode}"/></xsl:otherwise>
[22768]209 </xsl:choose>
210 </xsl:variable>
211
212 <!-- <a href="#" class="minmax">[+]</a><a href="#" class="remove">[x]</a><a href="#" class="remove"><img src="interfaces/oran/images/green_button_close.png" alt="[x]" title="Click me to remove"/></a><a href="[myhref]" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-home" style="float:left;"></span>Home</a> -->
[22987]213 <table class="header"><tbody><tr><td class="header">MATCH=<input 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>
[22768]214
[22676]215 <table class="table" border="1">
216 <tbody>
[22569]217 <tr class="tr">
[22829]218 <td class="droppable" width="10px"></td>
[22473]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>
[22569]223 </tr>
[22676]224 </tbody>
[22569]225 </table>
[22598]226 </div><br/>
[22473]227 </xsl:template>
[22458]228
[22516]229 <!-- ********** GSF:SWITCH ********** -->
230 <xsl:template match="gsf:switch" mode="xml-to-gui">
231 <xsl:param name="depth"/>
232 <xsl:param name="metadataSets"/>
233
[22598]234 <div class="gsf_switch css_gsf_switch block" title="gsf:switch">
[22987]235 <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>
[22516]236 <xsl:apply-templates mode="xml-to-gui">
237 <xsl:with-param name="depth" select="$depth"/>
238 <xsl:with-param name="metadataSets" select="$metadataSets"/>
239 </xsl:apply-templates>
240 </div>
241 </xsl:template>
242
243
244 <!-- ********** GSF:WHEN ********** -->
[22473]245 <xsl:template match="gsf:when" mode="xml-to-gui">
246 <xsl:param name="depth"/>
247 <xsl:param name="metadataSets"/>
[22458]248
[22598]249 <div class="gsf_when css_gsf_when block" title="gsf:when">
[22987]250 <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>
[22473]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 </div>
256 </xsl:template>
[22458]257
[22516]258
259 <!-- ********** GSF:OTHERWISE ********** -->
[22473]260 <xsl:template match="gsf:otherwise" mode="xml-to-gui">
261 <xsl:param name="depth"/>
262 <xsl:param name="metadataSets"/>
[22458]263
[22598]264 <div class="gsf_otherwise css_gsf_otherwise block" title="gsf:otherwise">
[22987]265 <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="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
[22473]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>
[22458]272
[22516]273
274 <!-- ********** GSF:ICON ********** -->
[22473]275 <xsl:template match="gsf:icon" mode="xml-to-gui">
276 <xsl:param name="depth"/>
277 <xsl:param name="metadataSets"/>
278
[22598]279 <div class="gsf_icon css_gsf_icon block leaf" title="gsf:icon">
[22768]280 <xsl:variable name="icon">
[22987]281 ICON<select>
[22516]282 <xsl:choose>
283 <xsl:when test="@type='document'">
284 <option value = "document" selected = "document">Document</option>
285 <option value = "classifier">Classifier</option>
286 <option value = "source">Source</option>
287 </xsl:when>
288 <xsl:when test="@type='classifier'">
289 <option value = "classifier" selected = "classifier">Classifier</option>
290 <option value = "document">Document</option>
291 <option value = "source">Source</option>
292 </xsl:when>
293 <xsl:when test="@type='source'">
294 <option value = "source" selected = "source">Source</option>
295 <option value ="document">Document</option>
296 <option value ="classifier">Classifier</option>
297 </xsl:when>
298 </xsl:choose>
[22987]299 </select>
[22768]300 </xsl:variable>
[22987]301 <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>
[22473]302 </div>
303 </xsl:template>
304
305
[22516]306 <!-- ********** GSF:DEFAULT ********** -->
[22473]307 <xsl:template match="gsf:default" mode="xml-to-gui">
308 <xsl:param name="depth"/>
309 <xsl:param name="metadataSets"/>
310
[22933]311 <div class="block gsf_default" title="gsf:default">
[22987]312 <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>
[22473]313 <xsl:apply-templates mode="xml-to-gui">
314 <xsl:with-param name="depth" select="$depth"/>
315 <xsl:with-param name="metadataSets" select="$metadataSets"/>
316 </xsl:apply-templates>
317 </div>
318 </xsl:template>
319
[22516]320
321 <!-- ********** TEXT ********** -->
[22473]322 <xsl:template match="text()" mode="xml-to-gui">
323 <xsl:param name="depth"/>
324 <xsl:param name="metadataSets"/>
325
[22933]326 <div class="block leaf gsf_text" title="gsf:text">
[22473]327 <xsl:variable name="rawtext"><xsl:value-of select="."/></xsl:variable>
[22987]328 <table class="header"><tbody><tr><td class="header"><input type="text" name="rawtextinput" size="10" value="{$rawtext}"/></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
[22473]329 </div>
330 </xsl:template>
331
[22516]332
333 <!-- ********** TABLE ********** -->
[22473]334 <xsl:template match="td" mode="xml-to-gui">
335 <xsl:param name="depth"/>
336 <xsl:param name="metadataSets"/>
[22569]337
[22473]338
[22569]339 <!-- <td class="td block resizable" title="td" valign="{@valign}" style='overflow: hidden;'> -->
340 <td valign="{@valign}" title="td">
[22829]341 <div class="td-div block" title="td-div">
342 <div class="neverempty block" style="height:50px">NEVER EMPTY</div>
343
[22569]344 <!-- <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> -->
[22516]345 <xsl:apply-templates mode="xml-to-gui">
346 <xsl:with-param name="depth" select="$depth"/>
347 <xsl:with-param name="metadataSets" select="$metadataSets"/>
348 </xsl:apply-templates>
[22569]349 <!-- <xsl:text>&lt;/td&gt;</xsl:text><br/><br/> -->
350 </div>
351 </td>
[22768]352 <td class="droppable" width="10px" title="Drag a new column on to me"/>
[22473]353 </xsl:template>
[22458]354
[22516]355
356 <!-- ********** BREAK ********** -->
[22473]357 <xsl:template match="br" mode="xml-to-gui">
358 <xsl:param name="depth"/>
359 <xsl:param name="metadataSets"/>
360
[22987]361 <!-- <xsl:text>&lt;br/&gt;</xsl:text> <br/> -->
[22473]362
[22458]363 <xsl:apply-templates mode="xml-to-gui">
[22473]364 <xsl:with-param name="depth" select="$depth"/>
365 <xsl:with-param name="metadataSets" select="$metadataSets"/>
[22458]366 </xsl:apply-templates>
[22473]367 </xsl:template>
[22458]368
[22516]369
370 <!-- ********** MATCH ALL ********** -->
[22473]371 <xsl:template match="*" mode="xml-to-gui">
372 <xsl:param name="depth"/>
373 <xsl:param name="metadataSets"/>
[22458]374
[22473]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:template>
[22458]380
381</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.