Index: /main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfigXMLReadWrite.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfigXMLReadWrite.java	(revision 22345)
+++ /main/trunk/gli/src/org/greenstone/gatherer/cdm/CollectionConfigXMLReadWrite.java	(revision 22346)
@@ -799,7 +799,36 @@
     toElement.appendChild (language_indexes);
   }
-  // Handling both searchType and search format statement
+
+  // Handling search types
+  static private void doSearchType (Document to, Node searchNode) {
+    NodeList type_children = ((Element)searchNode).getElementsByTagName (StaticStrings.SEARCHTYPE_ELEMENT);
+    int num_types = type_children.getLength();
+    String searchtype_str = "";
+    if (num_types < 1) {
+      // not defined yet, add in default
+      searchtype_str = "plain,simpleform,advancedform";
+    }
+    else {
+      for(int i=0; i<num_types; i++) {
+	Node e = type_children.item (i);
+	String t = ((Element)e).getAttribute (StaticStrings.NAME_ATTRIBUTE);
+	if (i>0) {
+	  searchtype_str += ",";
+	}
+	searchtype_str += t;
+      }
+    }
+    
+    // pretend its a format statement
+    Element search_type_element = to.createElement (StaticStrings.FORMAT_STR);
+    search_type_element.setAttribute (StaticStrings.NAME_ATTRIBUTE, StaticStrings.SEARCHTYPE_ELEMENT);
+    XMLTools.setNodeText(search_type_element, searchtype_str);
+    appendProperly (to.getDocumentElement (), search_type_element);
+    
+  }
+
+  // Handling search format statement
   static private void doSearchFormat (Document to, Node searchNode) {
-    //There are two elements called <format> in <search>: one is for searchType; another is for format statement
+    // THere is currently just one format element for search. HOwever, need to check for old config files which used to have <format name="searchTypes">
     NodeList format_children = ((Element)searchNode).getElementsByTagName (StaticStrings.FORMAT_STR);
     int format_nodes = format_children.getLength ();
@@ -808,13 +837,9 @@
     }
     Element format = null;
-    Element search_type = null;
     for(int i=0; i<format_nodes; i++) {
       Node e = format_children.item (i);
       if (e.hasAttributes () == false) {
-	//The format element for format statement has no any attribute
+	//The format element for format statement has no attribute
 	format = (Element)e;
-      }
-      else if (((Element)e).getAttribute (StaticStrings.NAME_ATTRIBUTE).equals(StaticStrings.SEARCHTYPE_ELEMENT)) {
-	search_type = (Element)e;
       }
     }
@@ -822,15 +847,4 @@
     if (format != null) {            
       (to.getDocumentElement ()).appendChild (doFormat(to, format, StaticStrings.SEARCH_STR));
-    }
-    // searchType in search
-    if(search_type != null) {
-      String searchtype_str = XMLTools.getNodeText(search_type);
-        
-      Element search_type_element = to.createElement (StaticStrings.FORMAT_STR);
-      search_type_element.setAttribute (StaticStrings.NAME_ATTRIBUTE, StaticStrings.SEARCHTYPE_ELEMENT);
-      XMLTools.setNodeText(search_type_element, searchtype_str);
-        
-        
-      appendProperly (to.getDocumentElement (), search_type_element);
     }
   }
@@ -1272,15 +1286,14 @@
       return;
     }
-    Element search_type_element = to.createElement (StaticStrings.FORMAT_STR);
-        
-    //        String searchtype_str = e.getAttribute (StaticStrings.VALUE_ATTRIBUTE);        
-    //        search_type_element.setAttribute (StaticStrings.VALUE_ATTRIBUTE, searchtype_str);
-    String searchtype_str = XMLTools.getNodeText(e);        
-    XMLTools.setNodeText(search_type_element, searchtype_str);
-        
-    search_type_element.setAttribute (StaticStrings.NAME_ATTRIBUTE, StaticStrings.SEARCHTYPE_ELEMENT);
+    String searchtype_str = XMLTools.getNodeText(e); 
     //Get the 'search' element from 'to'
     Element search = (Element)XMLTools.getChildByTagName (to.getDocumentElement (), StaticStrings.SEARCH_STR);
-    search.appendChild (search_type_element);
+
+    String[] types = searchtype_str.split(",");
+    for (int i=0; i<types.length; i++) {
+      Element search_type_element = to.createElement (StaticStrings.SEARCHTYPE_ELEMENT);
+      search_type_element.setAttribute(StaticStrings.NAME_ATTRIBUTE, types[i]);
+      search.appendChild (search_type_element);
+    }
   }
     
@@ -2001,5 +2014,4 @@
         
     doDefaultIndex (dOc, searchNode);
-    //doSearchType (dOc, searchNode);
     doDefaultLevel (dOc, searchNode);
     doLevel (dOc, searchNode);
@@ -2010,4 +2022,5 @@
     doDefaultIndexLanguage (dOc, searchNode);
     doLanguageMetadata (dOc, searchNode);
+    doSearchType (dOc, searchNode);
     doSearchFormat (dOc, searchNode);
     doDisplayFormat (dOc, fromElement);
