root/main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl @ 23135

Revision 23135, 19.5 KB (checked in by sjb48, 9 years ago)

Can now drag a metadata item and have it maintain selection

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