Index: trunk/gli/src/org/greenstone/gatherer/collection/BuildOptions.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/collection/BuildOptions.java	(revision 9134)
+++ 	(revision )
@@ -1,414 +1,0 @@
-package org.greenstone.gatherer.collection;
-
-import java.io.*;
-import java.lang.ref.*;
-import java.net.*;
-import java.util.*;
-import org.apache.xerces.parsers.DOMParser;
-import org.greenstone.gatherer.Configuration;
-import org.greenstone.gatherer.DebugStream;
-import org.greenstone.gatherer.Gatherer;
-import org.greenstone.gatherer.cdm.Argument;
-import org.greenstone.gatherer.util.ArrayTools;
-import org.greenstone.gatherer.util.Codec;
-import org.greenstone.gatherer.util.StaticStrings;
-import org.greenstone.gatherer.util.Utility;
-import org.greenstone.gatherer.util.XMLTools;
-import org.w3c.dom.*;
-import org.xml.sax.InputSource;
-
-/** Build options uses the argument list found in config.xml and the current settings from the loaded collection configuration to represent the options the user wants to use during import and build. If there are no arguments stored in config.xml, or if the user indicates the argument are out of date, this class tries to parse new ones. */
-public class BuildOptions {
-    /** The root element of the build argument tree. */
-    private Element build_arguments_element;
-    /** The root element of the build values tree. */
-    private Element build_values_element;
-    /** The root element of the import argument tree. */
-    private Element import_arguments_element;
-    /** The root element of the import values tree. */
-    private Element import_values_element;
-    /** A cache of previously created build arguments. */
-    private Hashtable build_arguments_cache = new Hashtable();
-    /** A cache of previously created import arguments. */
-    private Hashtable import_arguments_cache = new Hashtable();
-    /** The name of an argument element. */
-    static final private String ARGUMENT = "Argument";
-    /** The name of the enabled attribute. */
-    static final private String ENABLED = "enabled";
-    /** The name of the 'false' value. */
-    static final private String FALSE = "false";
-    /** The name of a name attribute. */
-    static final private String NAME = "name";
-    /** The name of an option element. */
-    static final private String OPTION = "Option";
-    /** The name of the 'true' value. */
-    static final private String TRUE = "true";
-    /** When constructing a BuildOptions object we first try to retrieve the valid arguments from config.xml. If that fails we then try to parse the arguments noticed when calling import.pl -xml and buildcol.pl -xml. If that also fails, we load the default arguments from the xml template library. */
-    public BuildOptions(Element build_values_element, Element import_values_element) {
-	// first check the saved arguments language
-	String interface_lang = Configuration.getLanguage();
-	String args_lang = Configuration.getArgumentsLanguage();
-	if (interface_lang.equals(args_lang)) {
-	    // Try to retrieve the arguments for import and build.
-	    build_arguments_element = Configuration.getArguments("buildcol.pl");
-	    import_arguments_element = Configuration.getArguments("import.pl");
-	}
-	// If that fails try to reconstruct the arguments
-	if(build_arguments_element == null || import_arguments_element == null) {
-	    boolean used_defaults = false;
-	    build_arguments_element = loadArguments("buildcol.pl", interface_lang);
-	    import_arguments_element = loadArguments("import.pl", interface_lang);
-	    // And if that too fails, load the default argument templates
-	    if(build_arguments_element == null || import_arguments_element == null) {
-		Document build_document = Utility.parse("xml/buildcol.xml", true);
-		build_arguments_element = build_document.getDocumentElement();
-		build_document = null;
-		Document import_document = Utility.parse("xml/import.xml", true);
-		import_arguments_element = import_document.getDocumentElement();
-		import_document = null;
-		used_defaults = true;
-		///atherer.println("Loaded default BO arguments from templates.");
-	    }
-	    else {
-		///atherer.println("Loaded BO arguments from scripts.");
-	    }
-	    // By now we should definately have the arguments. However the reason we are here is because they are not stored in the config.xml file, to make sure they are stored now.
-	    if (used_defaults) {
-		Configuration.setArgumentsLanguage("en");
-	    } else {
-		Configuration.setArgumentsLanguage(interface_lang);
-	    }
-	    Configuration.setArguments(build_arguments_element);
-	    Configuration.setArguments(import_arguments_element);
-	}
-	else {
-	    DebugStream.println("Loaded BO arguments from config.xml");
-	}
-	// Now take a note of the values too.
-	this.build_values_element = build_values_element;
-	this.import_values_element = import_values_element;
-    }
-
-    /** Retrieve the arguments associated with a certain type of action, ie import or build. */
-    public String[] getArguments(boolean build) {
-	String arguments[] = null;
-	NodeList argument_list = null;
-	if(build) {
-	    argument_list = build_values_element.getElementsByTagName(ARGUMENT);
-	}
-	else {
-	    argument_list = import_values_element.getElementsByTagName(ARGUMENT);
-	}
-	for(int i = 0; i < argument_list.getLength(); i++) {
-	    String[] temp = new String[2];
-	    Element argument = (Element) argument_list.item(i);
-	    ArrayTools.add(arguments, argument.getAttribute(NAME));
-	    String value = XMLTools.getValue(argument);
-	    if(value != null && value.length() > 0) {
-		ArrayTools.add(arguments, value);
-	    }
-	}
-	return arguments;
-    }
-
-    /** Retrieve the indexth argument belonging to build. */
-    public Argument getBuildArgument(int index) {
-	Argument argument = null;
-	// Try to find the argument in the cache.
-	SoftReference reference = (SoftReference) build_arguments_cache.get(new Integer(index));
-	if(reference != null) {
-	    argument = (Argument) reference.get();
-	}
-	// Otherwise generate a new argument.
-	if(argument == null) {
-	    argument = getArgument(build_arguments_element, index);
-	}
-	return argument;
-    }
-
-    /** Retrieve the number of arguments involved in building. 
-     */
-    public int getBuildArgumentCount() {
-	// Determining the total count is easy.
-	NodeList argument_elements = build_arguments_element.getElementsByTagName(OPTION);
-	return argument_elements.getLength();
-    }
-
-    /** Retrieve the value of a certain build argument. */
-    public String getBuildValue(String name) {
-	return getValue(build_values_element, name, false);
-    }
-
-    /** Determine if the named argument value is enabled or disabled. */
-    public boolean getBuildValueEnabled(String name) {
-	boolean result = false;
-	String value = getValue(build_values_element, name, true);
-	if(value != null && value.length() > 0) {
-	    result = (value.equalsIgnoreCase(TRUE));
-	}
-	return result;
-    }
-
-    /** Retrieve all of the build values as a String array ready to added to the buildcol.pl call. */
-    public String[] getBuildValues() {
-	return getValues(build_values_element);
-    }
-
-    /** Retrieve the indexth argument belonging to import. */
-    public Argument getImportArgument(int index) {
-	Argument argument = null;
-	// Try to find the argument in the cache.
-	SoftReference reference = (SoftReference) import_arguments_cache.get(new Integer(index));
-	if(reference != null) {
-	    argument = (Argument) reference.get();
-	}
-	// Otherwise generate a new argument.
-	if(argument == null) {
-	    argument = getArgument(import_arguments_element, index);
-	}
-	return argument;
-    }
-
-    /** Retrieve the number of arguments involved in importing. 
-     */
-    public int getImportArgumentCount() {
-	// Determining the total count is easy.
-	NodeList argument_elements = import_arguments_element.getElementsByTagName(OPTION);
-	return argument_elements.getLength();
-    }
-
-    /** Retrieve the value of a certain build argument. */
-    public String getImportValue(String name) {
-	return getValue(import_values_element, name, false);
-    }
-
-    /** Determine if the named argument value is enabled or disabled. */
-    public boolean getImportValueEnabled(String name) {
-	boolean result = false;
-	String value = getValue(import_values_element, name, true);
-	if(value != null && value.length() > 0) {
-	    result = (value.equalsIgnoreCase(TRUE));
-	}
-	return result;
-    }
-
-    /** Retrieve all of the import arguments in a form ready to be sent out to a shell process. */
-    public String[] getImportValues() {
-	return getValues(import_values_element);
-    }
-
-    /** Set the value of a build argument. */
-    public void setBuildValue(String name, boolean enable, String value) {
-	setValue(build_values_element, name, enable, value);
-    }
-
-    /** Set the value of a build argument. */
-    public void setImportValue(String name, boolean enable, String value) {
-	setValue(import_values_element, name, enable, value);
-    }	 
-
-    /** Remove the given build value. */
-    public void removeBuildValue(String name) {
-	removeValue(build_values_element, name);
-    }
-
-    /** Remove the given import value. */
-    public void removeImportValue(String name) {
-	removeValue(import_values_element, name);
-    }
-    
-    /** Retrieve the indexth element from the given set of arguments. */
-    private Argument getArgument(Element arguments_element, int index) {
-	NodeList option_list = arguments_element.getElementsByTagName(OPTION);
-	if(0 <= index && index < option_list.getLength()) {
-	    Argument argument = new Argument();
-	    argument.parseXML((Element) option_list.item(index));
-	    return argument;
-	}
-	return null; // no arg at this position
-    }
-
-    private String getValue(Element arguments_element, String name, boolean is_enabled) {
-	String result = null;
-	try {
-	    NodeList arguments = arguments_element.getElementsByTagName(ARGUMENT);
-	    for(int i = 0; result == null && i < arguments.getLength(); i++) {
-		Element argument_element = (Element) arguments.item(i);
-		// Is this the argument we want.
-		if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
-		    // Are we simply determining if this argument is enabled
-		    if(is_enabled) {
-			result = argument_element.getAttribute(ENABLED);
-		    }
-		    else {
-			String argument_value = XMLTools.getValue(argument_element);
-			if(argument_value != null) {
-			    result = argument_value;
-			}
-			argument_value = null;
-		    }
-		}
-		argument_element = null;
-	    }
-	    arguments = null;
-	}
-	catch (Exception error) {
-	    DebugStream.printStackTrace(error);
-	}
-	return result;
-    }
-
-    private String[] getValues(Element arguments_element) {
-	ArrayList values = new ArrayList();
-	try {
-	    NodeList arguments = arguments_element.getElementsByTagName(ARGUMENT);
-	    for(int i = 0; i < arguments.getLength(); i++) {
-		Element argument_element = (Element) arguments.item(i);
-		// Determine if this argument is enabled.
-		if(argument_element.getAttribute(ENABLED).equalsIgnoreCase(TRUE)) {
-		    // First store the name of the argument prefixed with a '-'
-		    values.add("-" + argument_element.getAttribute(NAME));
-		    // Now retrieve the value.
-		    String argument_value = Codec.transform(XMLTools.getValue(argument_element), Codec.DOM_TO_TEXT);
-		    // If there is a value, tokenize it by commas only.
-		    if(argument_value != null && argument_value.length() > 0) {
-			values.add(argument_value);
-		    }
-		    argument_value = null;
-		}
-		argument_element = null;
-	    }
-	    arguments = null;
-	}
-	catch (Exception error) {
-	    DebugStream.printStackTrace(error);
-	}
-	return ArrayTools.arrayListToStringArray(values);
-    }
-
-    private Element loadArguments(String filename, String lang) {
-	Element arguments_element = null;
-	InputStream input_stream = null;
-
-	// Run the required program.
-	try {
-	    String args[];
-	    if (Gatherer.isGsdlRemote) {
-		    String launch  = Gatherer.cgiBase + "launch";
-		    launch += "?cmd=" + filename;
-		    launch += "&xml=&language="+lang;
-
-		    System.err.println("*** launch = " + launch);
-
-		    URL launch_url = new URL(launch);
-		    URLConnection launch_connection = launch_url.openConnection();
-		    input_stream = launch_connection.getInputStream();
-	    }
-	    else {
-		if(Utility.isWindows()) {
-		    args = new String[6];
-		    args[0] = Configuration.perl_path;
-		    args[1] = "-S";
-		    args[2] = Configuration.getScriptPath() + filename;
-		    args[3] = "-xml";
-		    args[4] = "-language";
-		    args[5] = lang;
-		}
-		else {
-		    args = new String[4];
-		    args[0] = Configuration.getScriptPath() + filename;
-		    args[1] = "-xml";
-		    args[2] = "-language";
-		    args[3] = lang;
-		}
-
-		// Create the process.
-		Runtime runtime = Runtime.getRuntime();
-		Process process = runtime.exec(args);
-
-		input_stream = process.getErrorStream();
-	    }
-
-	    Document document = XMLTools.parseXML(input_stream);
-	    arguments_element = document.getDocumentElement();
-	}
-	catch (Exception error) {
-	    DebugStream.println("Error in BuildOptions.loadArguments(): " + error);
-	    DebugStream.printStackTrace(error);
-	}
-	return arguments_element;
-    }
-
-    /** Set the state of some build or import argument. Note that value may be either a single String, and ArrayList of Strings or null. If enable is false then any existing argument for the named argument is disabled. */
-    public void setValue(Element arguments_element, String name, boolean enable, String value) {
-	///ystem.err.println("Set value: " + (arguments_element == build_values_element ? "Build" : "Import") + ", " + name + ", " + enable + ", " + value);
-	try {
-	    Document document = arguments_element.getOwnerDocument();
-	    NodeList arguments = arguments_element.getElementsByTagName(ARGUMENT);
-	    boolean found = false;
-	    for(int i = 0; i < arguments.getLength(); i++) {
-		Element argument_element = (Element) arguments.item(i);
-		// If this the argument named.
-		if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
-		    found = true;
-		    // Set whether this argument is enabled
-		    argument_element.setAttribute(ENABLED, (enable ? TRUE : FALSE));
-		    // Now we set the value, depending or what it is.
-		    if(value == null) {
-			// Nothing to do.
-		    }
-		    else {
-			// Remove existing text nodes.
-			while(argument_element.hasChildNodes()) {
-			    argument_element.removeChild(argument_element.getFirstChild());
-			}
-			argument_element.appendChild(document.createTextNode((String)value));
-		    }
-		}
-		argument_element = null;
-	    }
-	    // If we haven't found an instance of this argument, but should have, then add it.
-	    if(!found && (enable || value != null)) {
-		Element argument_element = document.createElement(ARGUMENT);
-		argument_element.setAttribute(NAME, name);
-		argument_element.setAttribute(ENABLED, (enable ? TRUE : FALSE));
-		// Now we set the value, depending or what it is.
-		if(value == null) {
-		    // Nothing to do.
-		}
-		else {
-		    argument_element.appendChild(document.createTextNode((String)value));
-		}
-		arguments_element.appendChild(argument_element);
-	    }
-	    arguments = null;
-	    document = null;
-	    // Make sure the collection knows to save.
-	    Gatherer.c_man.getCollection().setSaved(false);
-	}
-	catch (Exception error) {
-	    DebugStream.printStackTrace(error);
-	}
-    }
-
-    /** Remove the named value from the given arguments element. */
-    private void removeValue(Element arguments_element, String name) {
-	try {
-	    NodeList arguments = arguments_element.getElementsByTagName(ARGUMENT);
-	    boolean found = false;
-	    for(int i = 0; !found && i < arguments.getLength(); i++) {
-		Element argument_element = (Element) arguments.item(i);
-		// Is this the argument we want.
-		if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
-		    arguments_element.removeChild(argument_element);
-		    found = true;
-		}
-		argument_element = null;
-	    }
-	    arguments = null;
-	}
-	catch (Exception error) {
-	    DebugStream.printStackTrace(error);
-	}
-    }
-}
Index: trunk/gli/src/org/greenstone/gatherer/collection/ScriptOptions.java
===================================================================
--- trunk/gli/src/org/greenstone/gatherer/collection/ScriptOptions.java	(revision 9135)
+++ trunk/gli/src/org/greenstone/gatherer/collection/ScriptOptions.java	(revision 9135)
@@ -0,0 +1,337 @@
+package org.greenstone.gatherer.collection;
+
+import java.io.*;
+import java.lang.ref.*;
+import java.net.*;
+import java.util.*;
+import org.apache.xerces.parsers.DOMParser;
+import org.greenstone.gatherer.Configuration;
+import org.greenstone.gatherer.DebugStream;
+import org.greenstone.gatherer.Gatherer;
+import org.greenstone.gatherer.cdm.Argument;
+import org.greenstone.gatherer.util.ArrayTools;
+import org.greenstone.gatherer.util.Codec;
+import org.greenstone.gatherer.util.StaticStrings;
+import org.greenstone.gatherer.util.Utility;
+import org.greenstone.gatherer.util.XMLTools;
+import org.w3c.dom.*;
+import org.xml.sax.InputSource;
+
+/** Build options uses the argument list found in config.xml and the current settings from the loaded collection configuration to represent the options the user wants to use during import and build. If there are no arguments stored in config.xml, or if the user indicates the argument are out of date, this class tries to parse new ones. */
+public class ScriptOptions {
+    /** The root element of the argument tree. */
+    private Element arguments_element;
+    /** The root element of the values tree. */
+    private Element values_element;
+    /** A cache of previously created arguments. */
+    private Hashtable arguments_cache = new Hashtable();
+    /** whether the values should be saved or not */
+    /** The name of an argument element. */
+    static final private String ARGUMENT = "Argument";
+    /** The name of the enabled attribute. */
+    static final private String ENABLED = "enabled";
+    /** The name of the 'false' value. */
+    static final private String FALSE = "false";
+    /** The name of a name attribute. */
+    static final private String NAME = "name";
+    /** The name of an option element. */
+    static final private String OPTION = "Option";
+    /** The name of the 'true' value. */
+    static final private String TRUE = "true";
+    /** When constructing a ScriptOptions object we first try to retrieve the valid arguments from config.xml - if saved is true. If that fails we then try to parse the arguments noticed when calling script_name -xml. If that also fails, we try to load the default arguments from the xml template library. */
+    public ScriptOptions(Element values_element, String script_name, boolean saved) {
+	// first check the saved arguments language
+	String interface_lang = Configuration.getLanguage();
+	String args_lang = Configuration.getArgumentsLanguage();
+	if (saved && interface_lang.equals(args_lang)) {
+	    // Try to retrieve the arguments for import and build.
+	    arguments_element = Configuration.getArguments(script_name);
+	}
+	// If that fails try to reconstruct the arguments
+	if(arguments_element == null) {
+	    boolean used_defaults = false;
+	    arguments_element = loadArguments(script_name, interface_lang);
+	   
+	    // And if that too fails, load the default argument templates
+	    if(arguments_element == null) {
+		// replace .pl with .xml to get the template name
+		String template_name = script_name.replaceAll("\\.pl$", "\\.xml");
+		Document document = Utility.parse("xml/"+template_name, true);
+		if (document != null) {
+		    arguments_element = document.getDocumentElement();
+		    document = null;
+		    used_defaults = true;
+
+		} else {
+		    return;
+		}
+		///atherer.println("Loaded default BO arguments from templates.");
+	    }
+	    else {
+		///atherer.println("Loaded BO arguments from scripts.");
+	    }
+	    // By now we should definately have the arguments. However the reason we are here is because they are not stored in the config.xml file, to make sure they are stored now.
+	    if (saved) {
+		if (used_defaults) {
+		    Configuration.setArgumentsLanguage("en");
+		} else {
+		    Configuration.setArgumentsLanguage(interface_lang);
+		}
+		Configuration.setArguments(arguments_element);
+	    }
+	}
+	else {
+	    DebugStream.println("Loaded BO arguments from config.xml");
+	}
+	// Now take a note of the values too.
+	this.values_element = values_element;
+    }
+
+    /** Retrieve the indexth argument */
+    public Argument getArgument(int index) {
+	Argument argument = null;
+	// Try to find the argument in the cache.
+	SoftReference reference = (SoftReference) arguments_cache.get(new Integer(index));
+	if(reference != null) {
+	    argument = (Argument) reference.get();
+	}
+	// Otherwise generate a new argument.
+	if(argument == null) {
+	    NodeList option_list = arguments_element.getElementsByTagName(OPTION);
+	    if(0 <= index && index < option_list.getLength()) {
+		argument = new Argument();
+		argument.parseXML((Element) option_list.item(index));
+	    }
+	}
+	return argument;
+    }
+
+
+    /** Retrieve the number of arguments.
+     */
+    public int getArgumentCount() {
+	// Determining the total count is easy.
+	NodeList argument_elements = arguments_element.getElementsByTagName(OPTION);
+	return argument_elements.getLength();
+    }
+
+    /** Retrieve all the argument names and values  */
+    public String[] getArguments() {
+	String arguments[] = null;
+	NodeList argument_list = null;
+	argument_list = values_element.getElementsByTagName(ARGUMENT);
+	for(int i = 0; i < argument_list.getLength(); i++) {
+	    String[] temp = new String[2];
+	    Element argument = (Element) argument_list.item(i);
+	    ArrayTools.add(arguments, argument.getAttribute(NAME));
+	    String value = XMLTools.getValue(argument);
+	    if(value != null && value.length() > 0) {
+		ArrayTools.add(arguments, value);
+	    }
+	}
+	return arguments;
+    }
+
+    /** Retrieve the value of a certain argument. */
+    public String getValue(String name) {
+	return getValue(name, false);
+    }
+
+    /** Determine if the named argument value is enabled or disabled. */
+    public boolean getValueEnabled(String name) {
+	boolean result = false;
+	String value = getValue(name, true);
+	if(value != null && value.length() > 0) {
+	    result = (value.equalsIgnoreCase(TRUE));
+	}
+	return result;
+    }
+
+    /** Retrieve all of the values as a String array ready to added to the script call. */
+    public String[] getValues() {
+	ArrayList values = new ArrayList();
+	try {
+	    NodeList arguments = values_element.getElementsByTagName(ARGUMENT);
+	    for(int i = 0; i < arguments.getLength(); i++) {
+		Element argument_element = (Element) arguments.item(i);
+		// Determine if this argument is enabled.
+		if(argument_element.getAttribute(ENABLED).equalsIgnoreCase(TRUE)) {
+		    // First store the name of the argument prefixed with a '-'
+		    values.add("-" + argument_element.getAttribute(NAME));
+		    // Now retrieve the value.
+		    String argument_value = Codec.transform(XMLTools.getValue(argument_element), Codec.DOM_TO_TEXT);
+		    // If there is a value, tokenize it by commas only.
+		    if(argument_value != null && argument_value.length() > 0) {
+			values.add(argument_value);
+		    }
+		    argument_value = null;
+		}
+		argument_element = null;
+	    }
+	    arguments = null;
+	}
+	catch (Exception error) {
+	    DebugStream.printStackTrace(error);
+	}
+	return ArrayTools.arrayListToStringArray(values);
+    }
+
+   /** Remove the named value from the arguments */
+    public void removeValue(String name) {
+	try {
+	    NodeList arguments = values_element.getElementsByTagName(ARGUMENT);
+	    boolean found = false;
+	    for(int i = 0; !found && i < arguments.getLength(); i++) {
+		Element argument_element = (Element) arguments.item(i);
+		// Is this the argument we want.
+		if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
+		    values_element.removeChild(argument_element);
+		    found = true;
+		}
+		argument_element = null;
+	    }
+	    arguments = null;
+	}
+	catch (Exception error) {
+	    DebugStream.printStackTrace(error);
+	}
+    }
+
+    /** Set the state of some argument. Note that value may be either a single String, an ArrayList of Strings or null. If enable is false then any existing argument for the named argument is disabled. */
+    public void setValue(String name, boolean enable, String value) {
+	///ystem.err.println("Set value: " + (arguments_element == build_values_element ? "Build" : "Import") + ", " + name + ", " + enable + ", " + value);
+	try {
+	    Document document = values_element.getOwnerDocument();
+	    NodeList arguments = values_element.getElementsByTagName(ARGUMENT);
+	    boolean found = false;
+	    for(int i = 0; i < arguments.getLength(); i++) {
+		Element argument_element = (Element) arguments.item(i);
+		// If this the argument named.
+		if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
+		    found = true;
+		    // Set whether this argument is enabled
+		    argument_element.setAttribute(ENABLED, (enable ? TRUE : FALSE));
+		    // Now we set the value, depending or what it is.
+		    if(value == null) {
+			// Nothing to do.
+		    }
+		    else {
+			// Remove existing text nodes.
+			while(argument_element.hasChildNodes()) {
+			    argument_element.removeChild(argument_element.getFirstChild());
+			}
+			argument_element.appendChild(document.createTextNode((String)value));
+		    }
+		}
+		argument_element = null;
+	    }
+	    // If we haven't found an instance of this argument, but should have, then add it.
+	    if(!found && (enable || value != null)) {
+		Element argument_element = document.createElement(ARGUMENT);
+		argument_element.setAttribute(NAME, name);
+		argument_element.setAttribute(ENABLED, (enable ? TRUE : FALSE));
+		// Now we set the value, depending or what it is.
+		if(value == null) {
+		    // Nothing to do.
+		}
+		else {
+		    argument_element.appendChild(document.createTextNode((String)value));
+		}
+		values_element.appendChild(argument_element);
+	    }
+	    arguments = null;
+	    document = null;
+	    // Make sure the collection knows to save.
+	    Gatherer.c_man.getCollection().setSaved(false);
+	}
+	catch (Exception error) {
+	    DebugStream.printStackTrace(error);
+	}
+    }
+
+ 
+    private String getValue(String name, boolean is_enabled) {
+	String result = null;
+	try {
+	    NodeList arguments = values_element.getElementsByTagName(ARGUMENT);
+	    for(int i = 0; result == null && i < arguments.getLength(); i++) {
+		Element argument_element = (Element) arguments.item(i);
+		// Is this the argument we want.
+		if(argument_element.getAttribute(NAME).equalsIgnoreCase(name)) {
+		    // Are we simply determining if this argument is enabled
+		    if(is_enabled) {
+			result = argument_element.getAttribute(ENABLED);
+		    }
+		    else {
+			String argument_value = XMLTools.getValue(argument_element);
+			if(argument_value != null) {
+			    result = argument_value;
+			}
+			argument_value = null;
+		    }
+		}
+		argument_element = null;
+	    }
+	    arguments = null;
+	}
+	catch (Exception error) {
+	    DebugStream.printStackTrace(error);
+	}
+	return result;
+    }
+
+
+    private Element loadArguments(String filename, String lang) {
+	Element arguments_element = null;
+	InputStream input_stream = null;
+
+	// Run the required program.
+	try {
+	    String args[];
+	    if (Gatherer.isGsdlRemote) {
+		    String launch  = Gatherer.cgiBase + "launch";
+		    launch += "?cmd=" + filename;
+		    launch += "&xml=&language="+lang;
+
+		    System.err.println("*** launch = " + launch);
+
+		    URL launch_url = new URL(launch);
+		    URLConnection launch_connection = launch_url.openConnection();
+		    input_stream = launch_connection.getInputStream();
+	    }
+	    else {
+		if(Utility.isWindows()) {
+		    args = new String[6];
+		    args[0] = Configuration.perl_path;
+		    args[1] = "-S";
+		    args[2] = Configuration.getScriptPath() + filename;
+		    args[3] = "-xml";
+		    args[4] = "-language";
+		    args[5] = lang;
+		}
+		else {
+		    args = new String[4];
+		    args[0] = Configuration.getScriptPath() + filename;
+		    args[1] = "-xml";
+		    args[2] = "-language";
+		    args[3] = lang;
+		}
+
+		// Create the process.
+		Runtime runtime = Runtime.getRuntime();
+		Process process = runtime.exec(args);
+
+		input_stream = process.getErrorStream();
+	    }
+
+	    Document document = XMLTools.parseXML(input_stream);
+	    arguments_element = document.getDocumentElement();
+	}
+	catch (Exception error) {
+	    DebugStream.println("Error in ScriptOptions.loadArguments(): " + error);
+	    DebugStream.printStackTrace(error);
+	}
+	return arguments_element;
+    }
+
+}
