Index: /trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java	(revision 4580)
+++ /trunk/gli/src/org/greenstone/gatherer/cdm/PlugInManager.java	(revision 4581)
@@ -51,42 +51,10 @@
  * @version 2.1
  */
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.StringReader;
-import java.util.Collections;
-import java.util.Vector;
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JScrollPane;
-import javax.swing.JSeparator;
-import javax.swing.JTextArea;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import java.util.*;
+import javax.swing.*;
+import javax.swing.event.*;
 import javax.swing.plaf.basic.BasicArrowButton;
 import org.apache.xerces.parsers.DOMParser;
@@ -98,6 +66,5 @@
 import org.greenstone.gatherer.cdm.PlugIn;
 import org.greenstone.gatherer.util.Utility;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
+import org.w3c.dom.*;
 import org.xml.sax.InputSource;
 /** This class is resposible for maintaining a list of known plug-ins, and importing new plugins using the parser. */
@@ -217,27 +184,42 @@
 		args[2] = getPlugInName(plugin);
 	    }
-	    for(int i = 0; i < args.length; i++) {
-		///ystem.out.print(args[i] + " ");
-	    }
-				///ystem.out.print("\n");
-				// Create the process.
+	    // Create the process.
 	    Runtime runtime = Runtime.getRuntime();
 	    Process process = runtime.exec(args);
-				//InputStream input_stream = process.getErrorStream();
+	    //InputStream input_stream = process.getErrorStream();
 	    BufferedReader error_in = new BufferedReader(new InputStreamReader(process.getErrorStream()));
 	    String line = "";
 	    StringBuffer xml = new StringBuffer("");
+	    boolean xml_content = false;
 	    while((line = error_in.readLine()) != null) {
-		xml.append(line);
-		xml.append("\n");
-	    }
-	    line = null;
+		if(xml_content) {
+		    xml.append(line);
+		    xml.append("\n");
+		}
+		else if(line.trim().startsWith("<?xml")) {
+			xml_content = true;
+			xml.append(line);
+			xml.append("\n");
+		}
+	    }
 	    error_in = null;
-				///ystem.out.println("\n");
-				// Then read the xml from the piped input stream.
-	    InputSource source = new InputSource(new StringReader(xml.toString()));
-	    DOMParser parser = new DOMParser();
-	    parser.parse(source);
-	    document = parser.getDocument();
+	    process = null;
+	    runtime = null;
+	    args = null;
+	    // If something has gone horribly wrong then xml will be empty.
+	    if(xml.length() != 0) {
+		// Then read the xml from the piped input stream.
+		InputSource source = new InputSource(new StringReader(xml.toString()));
+		DOMParser parser = new DOMParser();
+		parser.parse(source);
+		document = parser.getDocument();
+		parser = null;
+		source = null;
+	    }
+	    else {
+		String plugin_name = getPlugInName(plugin);
+		Gatherer.println("Zero length argument xml detected for: " + plugin_name);
+		JOptionPane.showMessageDialog(Gatherer.g_man, get("PlugIn_XML_Parse_Failed", plugin_name), get("General.Error"), JOptionPane.ERROR_MESSAGE);
+	    }
 	}
 	catch (Exception error) {
@@ -462,6 +444,13 @@
 	  */
     private String get(String key) {
-	return get(key, null);
-    }
+	return get(key, (String[])null);
+    }
+
+    private String get(String key, String arg) {
+	String args[] = new String[1];
+	args[0] = arg;
+	return get(key, args);
+    }
+
     /* Retrieve a phrase from the dictionary based on a certain key and arguments.
 	  * @param key The search <strong>String</strong>.
