Index: main/trunk/gli/src/org/greenstone/gatherer/cdm/Format4gs3Manager.java
===================================================================
--- main/trunk/gli/src/org/greenstone/gatherer/cdm/Format4gs3Manager.java	(revision 25576)
+++ main/trunk/gli/src/org/greenstone/gatherer/cdm/Format4gs3Manager.java	(revision 25610)
@@ -31,4 +31,6 @@
 import javax.swing.event.*;
 import javax.swing.undo.*;
+import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.greenstone.gatherer.Configuration;
 import org.greenstone.gatherer.DebugStream;
@@ -44,4 +46,5 @@
 import org.greenstone.gatherer.util.XMLTools;
 import org.w3c.dom.*;
+import org.xml.sax.InputSource;
 
 import java.awt.FontMetrics;
@@ -49,4 +52,5 @@
 import java.awt.Insets;
 import java.awt.Rectangle;
+import java.io.ByteArrayInputStream;
 
 /**
@@ -234,4 +238,14 @@
 		//Collections.sort (feature_model);
 		return feature_model;
+	}
+
+	private String addSurroundingTags(String xml)
+	{
+		return "<ROOTELEMENT>" + xml + "</ROOTELEMENT>";
+	}
+
+	private String removeSurrondingTags(String xml)
+	{
+		return xml.replace("<ROOTELEMENT>\n", "").replace("<ROOTELEMENT>", "").replace("</ROOTELEMENT>", "");
 	}
 
@@ -377,5 +391,5 @@
 			splitPane.add(center_pane, JSplitPane.BOTTOM);
 			splitPane.setDividerLocation(150);
-			
+
 			setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
 			setLayout(new BorderLayout());
@@ -503,5 +517,5 @@
 					if (msg.startsWith(XMLTools.WELLFORMED))
 					{
-						format.setPureFormat(Format4gs3.toOneLineFormat(format_str));
+						format.setPureFormat(format_str);
 						format.update();
 						format_list_model.refresh(format);
@@ -549,5 +563,25 @@
 					///ystem.err.println("There is an existing format!");
 					format_list.setSelectedValue(format, true);
-					editor_textarea.setText(format.getPureFormat());
+					Element formatElem = null;
+					try
+					{
+						InputSource is = new InputSource(new ByteArrayInputStream(addSurroundingTags(format.getPureFormat()).getBytes("utf-8")));
+						formatElem = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is).getDocumentElement();
+					}
+					catch (Exception ex)
+					{
+						ex.printStackTrace();
+					}
+
+					if (formatElem != null)
+					{
+						StringBuffer sb = new StringBuffer();
+						XMLTools.xmlNodeToString(sb, formatElem, true, "  ", 0);
+						editor_textarea.setText(removeSurrondingTags(sb.toString()));
+					}
+					else
+					{
+						editor_textarea.setText(format.getPureFormat());
+					}
 					editor_textarea.setCaretPosition(0);
 
@@ -614,5 +648,25 @@
 						existingFormat(format.getFeatureName().startsWith(Classifier.CLASSIFIER_PREFIX));
 
-						editor_textarea.setText(format.getPureFormat());
+						Element formatElem = null;
+						try
+						{
+							InputSource is = new InputSource(new ByteArrayInputStream(addSurroundingTags(format.getPureFormat()).getBytes("utf-8")));
+							formatElem = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is).getDocumentElement();
+						}
+						catch (Exception ex)
+						{
+							ex.printStackTrace();
+						}
+
+						if (formatElem != null)
+						{
+							StringBuffer sb = new StringBuffer();
+							XMLTools.xmlNodeToString(sb, formatElem, true, "  ", 0);
+							editor_textarea.setText(removeSurrondingTags(sb.toString()));
+						}
+						else
+						{
+							editor_textarea.setText(format.getPureFormat());
+						}
 						editor_textarea.setCaretPosition(0);
 
Index: main/trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java
===================================================================
--- main/trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java	(revision 25576)
+++ main/trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java	(revision 25610)
@@ -944,9 +944,9 @@
 	{
 		StringBuffer sb = new StringBuffer("");
-		xmlNodeToString(sb, e, true, 2);
+		xmlNodeToString(sb, e, true, "\t", 2);
 		return sb.toString();
 	}
 
-	private static void xmlNodeToString(StringBuffer sb, Node e, boolean indent, int depth)
+	public static void xmlNodeToString(StringBuffer sb, Node e, boolean indent, String indentString, int depth)
 	{
 		if (e.getNodeType() == Node.TEXT_NODE)
@@ -974,5 +974,5 @@
 			for (int i = 0; i < depth; i++)
 			{
-				sb.append('\t');
+				sb.append(indentString);
 			}
 		}
@@ -1033,5 +1033,5 @@
 			for (int i = 0; i < len; i++)
 			{
-				xmlNodeToString(sb, children.item(i), indent, depth + 1);
+				xmlNodeToString(sb, children.item(i), indent, indentString, depth + 1);
 			}
 
@@ -1040,5 +1040,5 @@
 				for (int i = 0; i < depth; i++)
 				{
-					sb.append('\t');
+					sb.append(indentString);
 				}
 			}
