Index: /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 23254)
+++ /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 23255)
@@ -47,5 +47,5 @@
     });
     
-    $(".element_type_gsf_choose_metadata").draggable({
+    $(".draggable_gsf_choose_metadata").draggable({
             cursor: 'crosshair',
             connectToSortable: '.td-div',
@@ -70,5 +70,5 @@
 
     // switch, when, otherwise, icon
-    $(".element_type_gsf_switch").draggable({
+    $(".draggable_gsf_switch").draggable({
             cursor: 'crosshair',
             connectToSortable: '.td-div',
@@ -77,5 +77,5 @@
     });
 
-    $(".element_type_gsf_when").draggable({
+    $(".draggable_gsf_when").draggable({
             cursor: 'crosshair',
             connectToSortable: '.gsf_switch',
@@ -84,5 +84,5 @@
     });
 
-    $(".element_type_gsf_otherwise").draggable({
+    $(".draggable_gsf_otherwise").draggable({
             cursor: 'crosshair',
             connectToSortable: '.gsf_switch',
@@ -91,5 +91,5 @@
     });
 
-    $(".element_type_gsf_icon").draggable({
+    $(".draggable_gsf_icon").draggable({
             cursor: 'crosshair',
             connectToSortable: '.gsf_link',
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 23254)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 23255)
@@ -187,21 +187,14 @@
     <td width="25%" valign="top">
         <h2> Elements to add </h2>
-        <div class="header element_type_gsf_template css_gsf_template" title="gsf:template">TEMPLATE</div>
-        <!-- <script type="text/javascript">
-        <xsl:text disable-output-escaping="yes">
-        var index = gsf_template_element.indexOf("<div class=\"");
-        var a = gsf_template_element.slice(0, index + "<div class=\"".length);
-        var b = gsf_template_element.slice(index + "<div class=\"".length + 1);
-        var c = a.concat(".element_type_gsf_template", b);
-        document.write(c);
-        </xsl:text>
-        </script> -->
-        <div class="header element_type_gsf_choose_metadata css_gsf_choose_metadata" title="gsf:choose-metadata">CHOOSE-METADATA</div>
-        <div class="draggable_gsf_metadata gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata"><table class="header"><tbody><tr><td class="header"><xsl:call-template name="meta-to-combo">
+        <!-- <div class="header element_type_gsf_template css_gsf_template" title="gsf:template">TEMPLATE</div> -->
+        <div class="draggable_gsf_template css_gsf_template block" title="gsf:template"><table class="header"><tbody><tr><td class="header">MATCH=<input type="text" name="rawtextinput" size="10"/></td><td><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table><table border="1"><tr class="tr"><td class="droppable" width="10px"></td></tr></table></div><br/>
+
+        <div class="draggable_gsf_choose css_gsf_choose_metadata block" title="gsf:choose-metadata"><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></div>
+
+        <div class="draggable_gsf_metadata css_gsf_metadata block" title="gsf:metadata"><table class="header"><tbody><tr><td class="header"><xsl:call-template name="meta-to-combo">
                         <xsl:with-param name="metadataSets" select="//metadataSetList"/>
                         <xsl:with-param name="current" select="ex.Title"/>
                      </xsl:call-template></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table></div>
-        <!-- <div class="header element_type_gsf_metadata css_gsf_metadata" title="gsf:metadata">METADATA</div> -->
-        <!-- <div class="header element_type_gsf_link css_gsf_link" title="gsf:link">LINK</div> -->
+
         <div class="draggable_gsf_link css_gsf_link block" title="gsf:link"><table class="header"><tbody><tr><td class="header">LINK<select>
                             <option value = "document" selected = "document">Document</option>
@@ -210,8 +203,12 @@
                             <option value = "horizontal">Horizontal</option>
                 </select></td><td><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table></div>
-        <div class="header element_type_gsf_switch css_gsf_switch" title="gsf:switch">SWITCH</div>
-        <div class="header element_type_gsf_when css_gsf_when" title="gsf:when">WHEN</div>
-        <div class="header element_type_gsf_otherwise css_gsf_otherwise" title="gsf:otherwise">OTHERWISE</div>
-        <div class="header element_type_gsf_icon css_gsf_icon" title="gsf:icon">ICON</div>
+
+        <div class="draggable_gsf_switch css_gsf_switch block" title="gsf:switch"><table class="header"><tbody><tr><td class="header">SWITCH</td><td><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table></div>
+
+        <div class="draggable_gsf_when css_gsf_when block" title="gsf:when"><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></div>
+
+        <div class="draggable_gsf_otherwise css_gsf_otherwise block" title="gsf:otherwise"><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><a href="#" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table></div>
+
+        <div class="draggable_gsf_icon css_gsf_icon block" title="gsf:icon"><table class="header"><tbody><tr><td class="header">ICON<select><option value = "document" selected = "document">Document</option><option value = "classifier">Classifier</option><option value = "source">Source</option></select></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table></div>
         <br/>
         <div class="element_type_text css_text" title="text">TEXT</div>
@@ -222,6 +219,4 @@
     </td>
     </table>
-
-    <!-- <xsl:variable name="tok" select="fn:tokenize($fmt,'/s+')"/> -->
 
     <div id="format">
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui-templates.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui-templates.xsl	(revision 23254)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui-templates.xsl	(revision 23255)
@@ -36,5 +36,4 @@
     <!-- ********** GSF:CHOOSE-METADATA ********** -->
         <xsl:variable name="choose_metadata">
-            <table class="header"><tbody><tr><td>CHOOSE</td><td><a href="#" class="minmax ui-icon ui-icon-minusthick" title="Click me to expand">[-]</a></td><td><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
             <div class="gsf_choose_metadata css_gsf_choose_metadata block" title="gsf:choose-metadata"><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></div>
         </xsl:variable>
@@ -47,10 +46,15 @@
     <!-- ********** GSF:METADATA ********** -->
         <xsl:variable name="metadata">
-        <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata"><table class="header"><tbody><tr><td class="header"><xsl:call-template name="meta-to-combo">
+        <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata">
+            <xsl:variable name="combo">
+                <xsl:call-template name="meta-to-combo">
                         <xsl:with-param name="metadataSets" select="$metadataSets"/>
-                        <xsl:with-param name="current" select="ex.title"/>
-                     </xsl:call-template></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table></div>
-                    <!-- <a href="#" class="remove">[x]</a></div> -->
-        </xsl:variable>
+                        <xsl:with-param name="current"/> 
+                     </xsl:call-template>
+            </xsl:variable>
+        <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>
+        </div>
+        
+        </xsl:variable> 
 
         <script type="text/javascript">
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl	(revision 23254)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl	(revision 23255)
@@ -54,20 +54,59 @@
     <xsl:template name="meta-to-combo">
         <xsl:param name="metadataSets" select='.'/>
-        <xsl:param name="current" select='.'/>
+        <xsl:param name="current" select='.'/> 
 
         <xsl:variable name="current_mod">
             <xsl:choose>
                 <xsl:when test="contains($current,'.')"><xsl:value-of select="$current"/></xsl:when>
-                <xsl:otherwise>ex.<xsl:value-of select="$current"/></xsl:otherwise>
+                <xsl:when test="$current!=''">ex.<xsl:value-of select="$current"/></xsl:when>
+                <xsl:otherwise>ex.Title</xsl:otherwise>
             </xsl:choose>
         </xsl:variable>
 
-        <select>
-            <!-- <option value ="{$current_mod}" disabled="disabled" selected="{$current_mod}"><xsl:value-of select="$current_mod"/></option> -->
-
-            <xsl:apply-templates select="$metadataSets" mode="meta-to-combo">
-                <xsl:with-param name="current" select="$current_mod"/>
-            </xsl:apply-templates>
-        </select>
+        <xsl:variable name="exists">
+        <xsl:apply-templates select="$metadataSets" mode="search-meta-to-combo">
+            <xsl:with-param name="current" select="$current_mod"/> <!--<xsl:copy-of select="$current_mod"/></xsl:with-param> -->
+        </xsl:apply-templates>
+        </xsl:variable>
+
+        <xsl:choose>
+            <xsl:when test="$exists='TRUE'">
+                <select>
+                    <xsl:apply-templates select="$metadataSets" mode="meta-to-combo">
+                        <xsl:with-param name="current" select="$current_mod"/>
+                    </xsl:apply-templates>
+                </select>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="$current_mod"/>
+            </xsl:otherwise>
+        </xsl:choose>
+
+    </xsl:template>
+
+    <xsl:template match="metadataSet" mode="search-meta-to-combo">
+        <xsl:param name="current"/>
+
+        <xsl:variable name="set"><xsl:value-of select="substring-before($current, '.')"/></xsl:variable>
+
+        <xsl:if test="@name=$set">
+        <xsl:apply-templates select="metadata" mode="search-meta-to-combo">
+            <!-- <xsl:with-param name="set" select="@name"/> --> <!-- name of the set -->
+            <xsl:with-param name="current" select="$current"/>
+        </xsl:apply-templates>
+        </xsl:if>
+    </xsl:template>
+
+    <xsl:template match="metadata" mode="search-meta-to-combo">
+        <xsl:param name="current"/>
+        <xsl:variable name="cur"><xsl:value-of select="substring-after($current, '.')"/></xsl:variable>
+        <xsl:if test="@name=$cur">TRUE</xsl:if>
+    </xsl:template>
+
+    <xsl:template match="*" mode="search-meta-to-combo">
+        <xsl:param name="current"/>
+        <xsl:apply-templates mode="search-meta-to-combo">
+            <xsl:with-param name="current" select="$current"/>
+        </xsl:apply-templates>
     </xsl:template>
 
@@ -76,5 +115,5 @@
 
         <xsl:apply-templates mode="meta-to-combo">
-            <xsl:with-param name="set" select="@name"/>
+            <xsl:with-param name="set" select="@name"/> <!-- name of the set -->
             <xsl:with-param name="current" select="$current"/>
         </xsl:apply-templates>
@@ -87,5 +126,4 @@
         <xsl:variable name="meta"><xsl:value-of select="$set"/>.<xsl:value-of select="@name"/></xsl:variable>
 
-        <!-- if this is the current value, then set combo box to this value -->
         <xsl:choose>
             <xsl:when test="$current = $meta">
@@ -134,4 +172,6 @@
         <xsl:param name="metadataSets"/>
 
+        <!-- DEBUG metadata: <xsl:value-of select="@name"/>eol -->
+
         <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata">
             <xsl:variable name="combo">
@@ -192,13 +232,4 @@
         <xsl:param name="depth"/>
         <xsl:param name="metadataSets"/>
-
-            <!-- CHILD = <xsl:value-of select="child[1]/@name"/> -->
-            <!-- CHILD = <xsl:value-of select="child::*[name()][1]"/> -->
-
-
-            <!-- <xsl:for-each select="child::*"> -->
-            <!-- <xsl:value-of select="name()"/> -->
-            <!-- </xsl:for-each> -->
-
 
         <div class="gsf_template css_gsf_template block" title="gsf:template">
@@ -211,5 +242,4 @@
             </xsl:variable>
     
-                    <!-- <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> -->
             <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>
 
@@ -264,5 +294,5 @@
 
         <div class="gsf_otherwise css_gsf_otherwise block" title="gsf:otherwise">
-                <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>
+                <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>
                 <xsl:apply-templates mode="xml-to-gui">
                     <xsl:with-param name="depth" select="$depth"/>
