Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java	(revision 24983)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java	(revision 24984)
@@ -1,20 +1,20 @@
 /*
-*    GSXML.java
-*    Copyright (C) 2008 New Zealand Digital Library, http://www.nzdl.org
-*
-*    This program is free software; you can redistribute it and/or modify
-*    it under the terms of the GNU General Public License as published by
-*    the Free Software Foundation; either version 2 of the License, or
-*    (at your option) any later version.
-*
-*    This program is distributed in the hope that it will be useful,
-*    but WITHOUT ANY WARRANTY; without even the implied warranty of
-*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*    GNU General Public License for more details.
-*
-*    You should have received a copy of the GNU General Public License
-*    along with this program; if not, write to the Free Software
-*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ *    GSXML.java
+ *    Copyright (C) 2008 New Zealand Digital Library, http://www.nzdl.org
+ *
+ *    This program is free software; you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation; either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program; if not, write to the Free Software
+ *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
 package org.greenstone.gsdl3.util;
 
@@ -44,5 +44,6 @@
 
 /** various functions for extracting info out of GS XML */
-public class GSXML {
+public class GSXML
+{
 
 	static Logger logger = Logger.getLogger(org.greenstone.gsdl3.util.GSXML.class.getName());
@@ -93,5 +94,5 @@
 
 	public static final String DBINFO_ELEM = "dbInfo";
-	public static final String DBNAME_ATT = "dbname";  
+	public static final String DBNAME_ATT = "dbname";
 	public static final String DBPATH_ATT = "dbpath";
 	public static final String SQLSTATE_ATT = "sqlstate";
@@ -100,5 +101,5 @@
 	public static final String NOTIFY_ELEM = "notify";
 	public static final String NOTIFY_HOST_ATT = "host";
-	
+
 	//doc.xml file elems
 	public static final String DOCXML_SECTION_ELEM = "Section";
@@ -116,6 +117,6 @@
 	//public final static String DESCRIPTION_ELEM = "description";
 
-	public static final String  ACTION_ELEM = "action";
-	public static final String  SUBACTION_ELEM = "subaction";
+	public static final String ACTION_ELEM = "action";
+	public static final String SUBACTION_ELEM = "subaction";
 
 	// add on to another elem type to get a list of that type
@@ -218,5 +219,5 @@
 	public static final String SERVICE_TYPE_OAI = "oai";
 	public static final String FLAX_PAGE = "flaxPage";
-	public static final String FLAX_PAGE_GENERATION = "FlaxPageGeneration";  
+	public static final String FLAX_PAGE_GENERATION = "FlaxPageGeneration";
 
 	// system command types and attributes
@@ -246,6 +247,6 @@
 
 	//for authentication
-	public static final String AUTHEN_NODE_ELEM="authenticationNode";
-	public static final String USER_NODE_ELEM="userNode";
+	public static final String AUTHEN_NODE_ELEM = "authenticationNode";
+	public static final String USER_NODE_ELEM = "userNode";
 
 	//for configure action results
@@ -253,66 +254,83 @@
 	public static final String ERROR = "error";
 
-	/** takes a list of elements, and returns an array of strings
-* of the values of attribute att_name */
-	public static String [] getAttributeValuesFromList(Element list,
-	String att_name) {
-		
+	/**
+	 * takes a list of elements, and returns an array of strings of the values
+	 * of attribute att_name
+	 */
+	public static String[] getAttributeValuesFromList(Element list, String att_name)
+	{
+
 		NodeList children = list.getChildNodes();
-		
+
 		int num_nodes = children.getLength();
-		String []ids = new String[num_nodes];
-		for (int i=0; i<num_nodes; i++) {
-			Element e = (Element)children.item(i);
+		String[] ids = new String[num_nodes];
+		for (int i = 0; i < num_nodes; i++)
+		{
+			Element e = (Element) children.item(i);
 			String id = e.getAttribute(att_name);
 			ids[i] = id;
 		}
-		
+
 		return ids;
 	}
 
-	public static HashMap extractParams(Element xml, boolean deep) {
+	public static HashMap extractParams(Element xml, boolean deep)
+	{
 		return extractParams(xml, deep, null);
 	}
 
-	/** takes a paramList element, and gets a HashMap of name-value pairs
-* if deep=true, extracts embedded params, otherwise just top level
-* params*/
-	public static HashMap extractParams(Element xml, boolean deep, String toFind) {
-		
-		if (!xml.getNodeName().equals(PARAM_ELEM+LIST_MODIFIER)) {
-			logger.error("paramList element should have been passed to extractParams, instead it was "+xml.getNodeName());
+	/**
+	 * takes a paramList element, and gets a HashMap of name-value pairs if
+	 * deep=true, extracts embedded params, otherwise just top level params
+	 */
+	public static HashMap extractParams(Element xml, boolean deep, String toFind)
+	{
+
+		if (!xml.getNodeName().equals(PARAM_ELEM + LIST_MODIFIER))
+		{
+			logger.error("paramList element should have been passed to extractParams, instead it was " + xml.getNodeName());
 			return null;
 		}
-		
+
 		NodeList params = null;
-		if (deep) { // get all the nested ones
+		if (deep)
+		{ // get all the nested ones
 			params = xml.getElementsByTagName(PARAM_ELEM);
-		} else { // just get the top  level ones
+		}
+		else
+		{ // just get the top  level ones
 			params = xml.getChildNodes();
 		}
 		HashMap param_map = new HashMap();
-		for (int i=0; i<params.getLength(); i++) {
-			if (params.item(i).getNodeName().equals(PARAM_ELEM)) {
-				Element param = (Element)params.item(i);
-				String name=param.getAttribute(NAME_ATT);
-				String value=getValue(param); //att or content
+		for (int i = 0; i < params.getLength(); i++)
+		{
+			if (params.item(i).getNodeName().equals(PARAM_ELEM))
+			{
+				Element param = (Element) params.item(i);
+				String name = param.getAttribute(NAME_ATT);
+				String value = getValue(param); //att or content
 
 				// For only one parameter
-				if(toFind != null && name.equals(toFind)) {
+				if (toFind != null && name.equals(toFind))
+				{
 					param_map.put(name, value);
 					return param_map;
-				}		
-				else if(toFind != null)
-				continue;
+				}
+				else if (toFind != null)
+					continue;
 
 				int pos = name.indexOf('.');
-				if (pos == -1) { // a base param
+				if (pos == -1)
+				{ // a base param
 					param_map.put(name, value);
-				} else { // a namespaced param
-					
+				}
+				else
+				{ // a namespaced param
+
 					String namespace = name.substring(0, pos);
-					name = name.substring(pos+1);
-					HashMap map = (HashMap)param_map.get(namespace);
-					if (map == null) {
+					name = name.substring(pos + 1);
+					HashMap map = (HashMap) param_map.get(namespace);
+					if (map == null)
+					{
 						map = new HashMap();
 						param_map.put(namespace, map);
@@ -326,11 +344,15 @@
 
 	/** gets the value att or the text content */
-	public static String getValue(Element e) {
+	public static String getValue(Element e)
+	{
 		String val = e.getAttribute(VALUE_ATT);
-		if (val ==null || val.equals("")) {
+		if (val == null || val.equals(""))
+		{
 			// have to get it out of the text
-			val=getNodeText(e);
-			
-		} else {
+			val = getNodeText(e);
+
+		}
+		else
+		{
 			// unescape the xml stuff
 			val = unXmlSafe(val);
@@ -340,9 +362,11 @@
 
 	/** extracts the text out of a node */
-	public static Node getNodeTextNode(Element param) {
+	public static Node getNodeTextNode(Element param)
+	{
 		param.normalize();
 		Node n = param.getFirstChild();
-		while (n!=null && n.getNodeType() !=Node.TEXT_NODE) {
-			n=n.getNextSibling();
+		while (n != null && n.getNodeType() != Node.TEXT_NODE)
+		{
+			n = n.getNextSibling();
 		}
 		return n;
@@ -350,7 +374,9 @@
 
 	/** extracts the text out of a node */
-	public static String getNodeText(Element param) {
+	public static String getNodeText(Element param)
+	{
 		Node text_node = getNodeTextNode(param);
-		if (text_node == null) {
+		if (text_node == null)
+		{
 			return "";
 		}
@@ -358,7 +384,9 @@
 	}
 
-	public static void setNodeText(Element elem, String text) {
+	public static void setNodeText(Element elem, String text)
+	{
 		Node old_text_node = getNodeTextNode(elem);
-		if (old_text_node != null) {
+		if (old_text_node != null)
+		{
 			elem.removeChild(old_text_node);
 		}
@@ -367,7 +395,8 @@
 	}
 
-	/** add text to a document/subsection  element */
-	public static boolean addDocText(Document owner, Element doc, String text) {
-		
+	/** add text to a document/subsection element */
+	public static boolean addDocText(Document owner, Element doc, String text)
+	{
+
 		Element content = owner.createElement(NODE_CONTENT_ELEM);
 		Text t = owner.createTextNode(text);
@@ -378,11 +407,13 @@
 
 	/** add an error message, unknown error type */
-	public static boolean addError(Document owner, Element doc, String text) {
+	public static boolean addError(Document owner, Element doc, String text)
+	{
 		return addError(owner, doc, text, ERROR_TYPE_OTHER);
 	}
+
 	/** add an error message */
-	public static boolean addError(Document owner, Element doc, String text,
-	String error_type) {
-		
+	public static boolean addError(Document owner, Element doc, String text, String error_type)
+	{
+
 		Element content = owner.createElement(ERROR_ELEM);
 		content.setAttribute(ERROR_TYPE_ATT, error_type);
@@ -394,21 +425,24 @@
 
 	/** add an error message */
-	public static boolean addError(Document owner, Element doc, Throwable error) {
+	public static boolean addError(Document owner, Element doc, Throwable error)
+	{
 		return addError(owner, doc, error, ERROR_TYPE_OTHER);
 	}
 
 	/** add an error message */
-	public static boolean addError(Document owner, Element doc,
-	Throwable error, String error_type) {
+	public static boolean addError(Document owner, Element doc, Throwable error, String error_type)
+	{
 		error.printStackTrace();
 		return addError(owner, doc, error.toString(), error_type);
 	}
 
-	public static Element createMetadataParamList(Document owner, Vector meta_values) {
-		
-		Element meta_param_list = owner.createElement(PARAM_ELEM+LIST_MODIFIER);
+	public static Element createMetadataParamList(Document owner, Vector meta_values)
+	{
+
+		Element meta_param_list = owner.createElement(PARAM_ELEM + LIST_MODIFIER);
 		Iterator i = meta_values.iterator();
-		while(i.hasNext()) {
-			String next = (String)i.next();
+		while (i.hasNext())
+		{
+			String next = (String) i.next();
 			Element meta_param = owner.createElement(PARAM_ELEM);
 			meta_param_list.appendChild(meta_param);
@@ -420,7 +454,8 @@
 
 	/** adds a metadata elem to a list */
-	public static boolean addMetadata(Document owner, Element list,
-	String meta_name, String meta_value) {
-		if (meta_value==null || meta_value.equals("")) {
+	public static boolean addMetadata(Document owner, Element list, String meta_name, String meta_value)
+	{
+		if (meta_value == null || meta_value.equals(""))
+		{
 			return false;
 		}
@@ -431,12 +466,16 @@
 		list.appendChild(data);
 		return true;
-		
-	}
-
-	/** copies the metadata out of the metadataList of 'from' into
-* the metadataList of 'to' */
-	public static boolean mergeMetadataLists(Node to, Node from) {
-		Node from_meta = getChildByTagName(from, METADATA_ELEM+LIST_MODIFIER);
-		if  (from_meta == null) { // nothing to copy
+
+	}
+
+	/**
+	 * copies the metadata out of the metadataList of 'from' into the
+	 * metadataList of 'to'
+	 */
+	public static boolean mergeMetadataLists(Node to, Node from)
+	{
+		Node from_meta = getChildByTagName(from, METADATA_ELEM + LIST_MODIFIER);
+		if (from_meta == null)
+		{ // nothing to copy
 			return true;
 		}
@@ -444,19 +483,24 @@
 	}
 
-
-	/** copies the metadata out of the meta_list metadataList  into
-* the metadataList of 'to' */
-	public static boolean mergeMetadataFromList(Node to, Node meta_list) {
-		if (meta_list == null) return false;
-		Node to_meta = getChildByTagName(to, METADATA_ELEM+LIST_MODIFIER);
+	/**
+	 * copies the metadata out of the meta_list metadataList into the
+	 * metadataList of 'to'
+	 */
+	public static boolean mergeMetadataFromList(Node to, Node meta_list)
+	{
+		if (meta_list == null)
+			return false;
+		Node to_meta = getChildByTagName(to, METADATA_ELEM + LIST_MODIFIER);
 		Document to_owner = to.getOwnerDocument();
-		if (to_meta == null) {
+		if (to_meta == null)
+		{
 			to.appendChild(to_owner.importNode(meta_list, true));
 			return true;
 		}
 		// copy individual metadata elements
-		NodeList meta_items = ((Element)meta_list).getElementsByTagName(METADATA_ELEM);
-		for (int i=0; i<meta_items.getLength(); i++) {
-			to_meta.appendChild(to_owner.importNode(meta_items.item(i),true));
+		NodeList meta_items = ((Element) meta_list).getElementsByTagName(METADATA_ELEM);
+		for (int i = 0; i < meta_items.getLength(); i++)
+		{
+			to_meta.appendChild(to_owner.importNode(meta_items.item(i), true));
 		}
 		return true;
@@ -464,9 +508,11 @@
 
 	/** copies all the children from from to to */
-	public static boolean mergeElements(Element to, Element from) {
-		
+	public static boolean mergeElements(Element to, Element from)
+	{
+
 		Document owner = to.getOwnerDocument();
 		Node child = from.getFirstChild();
-		while (child != null) {
+		while (child != null)
+		{
 			to.appendChild(owner.importNode(child, true));
 			child = child.getNextSibling();
@@ -474,11 +520,15 @@
 		return true;
 	}
+
 	/** returns the (first) element child of the node n */
-	public static Element getFirstElementChild(Node n) {
-		
+	public static Element getFirstElementChild(Node n)
+	{
+
 		Node child = n.getFirstChild();
-		while (child!=null) {
-			if (child.getNodeType() == Node.ELEMENT_NODE) {
-				return (Element)child;
+		while (child != null)
+		{
+			if (child.getNodeType() == Node.ELEMENT_NODE)
+			{
+				return (Element) child;
 			}
 			child = child.getNextSibling();
@@ -486,7 +536,10 @@
 		return null; //no element child found
 	}
+
 	/** returns the (first) child element with the given name */
-	public static Node getChildByTagName(Node n, String name) {
-		if(n != null) { // this line is an attempted solution to the NullPointerException mentioned 
+	public static Node getChildByTagName(Node n, String name)
+	{
+		if (n != null)
+		{ // this line is an attempted solution to the NullPointerException mentioned 
 			// in trac bug ticket #225. If n is null can't do n.getFirstChild() below. As per bug #225: 
 			// GSXML.getNodeByPath() is called by GS2BrowseAction, which then calls this method.
@@ -495,6 +548,8 @@
 
 			Node child = n.getFirstChild();
-			while (child!=null) {
-				if (child.getNodeName().equals(name)) {
+			while (child != null)
+			{
+				if (child.getNodeName().equals(name))
+				{
 					return child;
 				}
@@ -505,17 +560,26 @@
 	}
 
-	/** returns the (nth) child element with the given name
-* index numbers start at 0 */
-	public static Node getChildByTagNameIndexed(Node n, String name, int index) {
-		if (index == -1) {
+	/**
+	 * returns the (nth) child element with the given name index numbers start
+	 * at 0
+	 */
+	public static Node getChildByTagNameIndexed(Node n, String name, int index)
+	{
+		if (index == -1)
+		{
 			return getChildByTagName(n, name);
 		}
 		int count = 0;
 		Node child = n.getFirstChild();
-		while (child!=null) {
-			if (child.getNodeName().equals(name)) {
-				if (count == index) {
+		while (child != null)
+		{
+			if (child.getNodeName().equals(name))
+			{
+				if (count == index)
+				{
 					return child;
-				} else {
+				}
+				else
+				{
 					count++;
 				}
@@ -526,13 +590,18 @@
 	}
 
-	/** takes an xpath type expression of the form name/name/...
-* and returns the first node that matches, or null if not found */
-	public static Node getNodeByPath(Node n, String path) {
-		
+	/**
+	 * takes an xpath type expression of the form name/name/... and returns the
+	 * first node that matches, or null if not found
+	 */
+	public static Node getNodeByPath(Node n, String path)
+	{
+
 		String link = GSPath.getFirstLink(path);
 		path = GSPath.removeFirstLink(path);
-		while (!link.equals("")) {
+		while (!link.equals(""))
+		{
 			n = getChildByTagName(n, link);
-			if (n==null) {
+			if (n == null)
+			{
 				return null;
 			}
@@ -543,23 +612,30 @@
 	}
 
-	/** takes an xpath type expression of the form name/name/...
-* and returns the first node that matches, or null if not found
-* can include [i] indices. index numbers start at 0 */
-	public static Node getNodeByPathIndexed(Node n, String path) {
-		
+	/**
+	 * takes an xpath type expression of the form name/name/... and returns the
+	 * first node that matches, or null if not found can include [i] indices.
+	 * index numbers start at 0
+	 */
+	public static Node getNodeByPathIndexed(Node n, String path)
+	{
+
 		String link = GSPath.getFirstLink(path);
 		int index = GSPath.getIndex(link);
-		if (index != -1) {
+		if (index != -1)
+		{
 			link = GSPath.removeIndex(link);
 		}
 		path = GSPath.removeFirstLink(path);
-		while (!link.equals("")) {
+		while (!link.equals(""))
+		{
 			n = getChildByTagNameIndexed(n, link, index);
-			if (n==null) {
+			if (n == null)
+			{
 				return null;
 			}
 			link = GSPath.getFirstLink(path);
 			index = GSPath.getIndex(link);
-			if (index != -1) {
+			if (index != -1)
+			{
 				link = GSPath.removeIndex(link);
 			}
@@ -569,9 +645,11 @@
 	}
 
-	public static HashMap getChildrenMap(Node n) {
-		
-		HashMap map= new HashMap();
+	public static HashMap getChildrenMap(Node n)
+	{
+
+		HashMap map = new HashMap();
 		Node child = n.getFirstChild();
-		while (child!=null) {
+		while (child != null)
+		{
 			String name = child.getNodeName();
 			map.put(name, child);
@@ -581,9 +659,12 @@
 	}
 
-	public static NodeList getChildrenByTagName(Node n, String name) {
+	public static NodeList getChildrenByTagName(Node n, String name)
+	{
 		MyNodeList node_list = new MyNodeList();
 		Node child = n.getFirstChild();
-		while (child!=null) {
-			if (child.getNodeName().equals(name)) {
+		while (child != null)
+		{
+			if (child.getNodeName().equals(name))
+			{
 				node_list.addNode(child);
 			}
@@ -593,56 +674,59 @@
 	}
 
-
 	/** Duplicates an element, but gives it a new name */
-	public static Element duplicateWithNewName(Document owner, Element element,
-	String element_name, boolean with_attributes) {
+	public static Element duplicateWithNewName(Document owner, Element element, String element_name, boolean with_attributes)
+	{
 		return duplicateWithNewNameNS(owner, element, element_name, null, with_attributes);
 	}
 
 	/** Duplicates an element, but gives it a new name */
-	public static Element duplicateWithNewNameNS(Document owner,
-	Element element,
-	String element_name,
-	String namespace_uri,
-	boolean with_attributes) {
+	public static Element duplicateWithNewNameNS(Document owner, Element element, String element_name, String namespace_uri, boolean with_attributes)
+	{
 		Element duplicate;
-		if (namespace_uri == null) {
+		if (namespace_uri == null)
+		{
 			duplicate = owner.createElement(element_name);
-		} else {
+		}
+		else
+		{
 			duplicate = owner.createElementNS(namespace_uri, element_name);
 		}
 		// Copy element attributes
-		if (with_attributes) {
+		if (with_attributes)
+		{
 			NamedNodeMap attributes = element.getAttributes();
-			for (int i = 0; i < attributes.getLength(); i++) {
+			for (int i = 0; i < attributes.getLength(); i++)
+			{
 				Node attribute = attributes.item(i);
 				duplicate.setAttribute(attribute.getNodeName(), attribute.getNodeValue());
 			}
 		}
-		
+
 		// Copy element children
 		NodeList children = element.getChildNodes();
-		for (int i = 0; i < children.getLength(); i++) {
+		for (int i = 0; i < children.getLength(); i++)
+		{
 			Node child = children.item(i);
 			duplicate.appendChild(owner.importNode(child, true));
 		}
-		
+
 		return duplicate;
 	}
 
-	public static void copyAllChildren(Element to, Element from) {
-		
+	public static void copyAllChildren(Element to, Element from)
+	{
+
 		Document to_doc = to.getOwnerDocument();
 		Node child = from.getFirstChild();
-		while (child != null) {
+		while (child != null)
+		{
 			to.appendChild(to_doc.importNode(child, true));
 			child = child.getNextSibling();
 		}
 	}
+
 	/** returns a basic request message */
-	public static  Element createBasicRequest(Document owner,
-	String request_type, String to,
-	String lang,
-	String uid) {
+	public static Element createBasicRequest(Document owner, String request_type, String to, String lang, String uid)
+	{
 		Element request = owner.createElement(REQUEST_ELEM);
 		request.setAttribute(TYPE_ATT, request_type);
@@ -652,5 +736,5 @@
 		return request;
 	}
-	
+
 	public static Element createBasicResponse(Document owner, String from)
 	{
@@ -660,5 +744,5 @@
 		return response;
 	}
-	
+
 	public static Element createMetadataElement(Document owner, String name, String value)
 	{
@@ -669,15 +753,15 @@
 	}
 
-	public static Element createTextElement(Document owner, String elem_name,
-	String text) {
+	public static Element createTextElement(Document owner, String elem_name, String text)
+	{
 		Element e = owner.createElement(elem_name);
 		Text t = owner.createTextNode(text);
 		e.appendChild(t);
 		return e;
-		
-	}
-
-	public static Element createTextElement(Document owner, String elem_name,
-	String text, String att_name, String att_value) {
+
+	}
+
+	public static Element createTextElement(Document owner, String elem_name, String text, String att_name, String att_value)
+	{
 		Element e = owner.createElement(elem_name);
 		e.setAttribute(att_name, att_value);
@@ -685,10 +769,9 @@
 		e.appendChild(t);
 		return e;
-		
-	}
-	
-	public static Element createDisplayTextElement(Document owner,
-	String text_name,
-	String text) {
+
+	}
+
+	public static Element createDisplayTextElement(Document owner, String text_name, String text)
+	{
 		Element e = owner.createElement(DISPLAY_TEXT_ELEM);
 		e.setAttribute(NAME_ATT, text_name);
@@ -696,10 +779,9 @@
 		e.appendChild(t);
 		return e;
-		
-	}
-
-
-	public static Element createParameter(Document owner, String name,
-	String value) {
+
+	}
+
+	public static Element createParameter(Document owner, String name, String value)
+	{
 		Element param = owner.createElement(PARAM_ELEM);
 		param.setAttribute(NAME_ATT, name);
@@ -708,39 +790,37 @@
 	}
 
-	public static void addParametersToList(Document owner, Element param_list,
-	HashMap params) {
+	public static void addParametersToList(Document owner, Element param_list, HashMap params)
+	{
 		if (params == null)
 		{
 			return;
 		}
-		
+
 		Set items = params.entrySet();
 		Iterator i = items.iterator();
-		while(i.hasNext()) {
-			Map.Entry m = (Map.Entry)i.next();
-			param_list.appendChild(createParameter(owner, (String)m.getKey(), (String)m.getValue()));
-		}
-		
-	}
-
-	public static Element createParameterDescription(Document owner,
-	String id,
-	String display_name,
-	String type,
-	String default_value,
-	String []option_ids,
-	String []option_names) {
-		
-		
+		while (i.hasNext())
+		{
+			Map.Entry m = (Map.Entry) i.next();
+			param_list.appendChild(createParameter(owner, (String) m.getKey(), (String) m.getValue()));
+		}
+
+	}
+
+	public static Element createParameterDescription(Document owner, String id, String display_name, String type, String default_value, String[] option_ids, String[] option_names)
+	{
+
 		Element p = owner.createElement(PARAM_ELEM);
 		p.setAttribute(NAME_ATT, id);
 		p.setAttribute(TYPE_ATT, type);
 		p.appendChild(createDisplayTextElement(owner, GSXML.DISPLAY_TEXT_NAME, display_name));
-		
-		if (default_value != null) {
+
+		if (default_value != null)
+		{
 			p.setAttribute(DEFAULT_ATT, default_value);
 		}
-		if (option_ids!=null && option_names!=null) {
-			for (int i=0; i<option_ids.length; i++) {
+		if (option_ids != null && option_names != null)
+		{
+			for (int i = 0; i < option_ids.length; i++)
+			{
 				Element e = owner.createElement(PARAM_OPTION_ELEM);
 				e.setAttribute(NAME_ATT, option_ids[i]);
@@ -751,25 +831,23 @@
 		return p;
 	}
-	public static Element createParameterDescription2(Document owner,
-	String id,
-	String display_name,
-	String type,
-	String default_value,
-	ArrayList option_ids,
-	ArrayList option_names) {
-		
-		
+
+	public static Element createParameterDescription2(Document owner, String id, String display_name, String type, String default_value, ArrayList option_ids, ArrayList option_names)
+	{
+
 		Element p = owner.createElement(PARAM_ELEM);
 		p.setAttribute(NAME_ATT, id);
 		p.setAttribute(TYPE_ATT, type);
 		p.appendChild(createDisplayTextElement(owner, GSXML.DISPLAY_TEXT_NAME, display_name));
-		if (default_value != null) {
+		if (default_value != null)
+		{
 			p.setAttribute(DEFAULT_ATT, default_value);
 		}
-		if (option_ids!=null && option_names!=null) {
-			for (int i=0; i<option_ids.size(); i++) {
+		if (option_ids != null && option_names != null)
+		{
+			for (int i = 0; i < option_ids.size(); i++)
+			{
 				Element e = owner.createElement(PARAM_OPTION_ELEM);
-				e.setAttribute(NAME_ATT, (String)option_ids.get(i));
-				e.appendChild(createDisplayTextElement(owner, GSXML.DISPLAY_TEXT_NAME, (String)option_names.get(i)));
+				e.setAttribute(NAME_ATT, (String) option_ids.get(i));
+				e.appendChild(createDisplayTextElement(owner, GSXML.DISPLAY_TEXT_NAME, (String) option_names.get(i)));
 				p.appendChild(e);
 			}
@@ -778,17 +856,16 @@
 	}
 
-
-	/** returns the element parent/node_name[@attribute_name='attribute_value']
-*/
-	public static Element getNamedElement(Element parent, String node_name,
-	String attribute_name,
-	String attribute_value) {
-		
+	/** returns the element parent/node_name[@attribute_name='attribute_value'] */
+	public static Element getNamedElement(Element parent, String node_name, String attribute_name, String attribute_value)
+	{
+
 		NodeList children = parent.getChildNodes();
-		for (int i=0; i<children.getLength(); i++) {
+		for (int i = 0; i < children.getLength(); i++)
+		{
 			Node child = children.item(i);
-			if (child.getNodeName().equals(node_name)) {
-				if (((Element)child).getAttribute(attribute_name).equals(attribute_value))
-				return (Element)child;
+			if (child.getNodeName().equals(node_name))
+			{
+				if (((Element) child).getAttribute(attribute_name).equals(attribute_value))
+					return (Element) child;
 			}
 		}
@@ -796,19 +873,26 @@
 		return null;
 	}
-	/** returns a NodeList of elements: ancestor/node_name[@attribute_name='attribute_value']
-*/
-	public static NodeList getNamedElements(Element ancestor, String node_name, String attribute_name, String attribute_value) {
+
+	/**
+	 * returns a NodeList of elements:
+	 * ancestor/node_name[@attribute_name='attribute_value']
+	 */
+	public static NodeList getNamedElements(Element ancestor, String node_name, String attribute_name, String attribute_value)
+	{
 		MyNodeList node_list = new MyNodeList();
 		NodeList children = ancestor.getElementsByTagName(node_name);
-		
-		if(children != null && children.getLength() > 0) {
-			
-			for (int i=0; i<children.getLength(); i++) {
+
+		if (children != null && children.getLength() > 0)
+		{
+
+			for (int i = 0; i < children.getLength(); i++)
+			{
 				Node child = children.item(i);
-				if (child.getNodeName().equals(node_name)) {
-					if (((Element)child).getAttribute(attribute_name).equals(attribute_value))
-					node_list.addNode(child);
-				}			
-			}			
+				if (child.getNodeName().equals(node_name))
+				{
+					if (((Element) child).getAttribute(attribute_name).equals(attribute_value))
+						node_list.addNode(child);
+				}
+			}
 		}
 		return node_list;
@@ -820,65 +904,80 @@
 
 	// sort type:
-	public static Element insertIntoOrderedList(Element parent_node,
-	String node_name,
-	Element start_from_elem,
-	Element new_elem, String sort_att,
-	boolean descending) {
-		if (new_elem == null) return null;
-		Element cloned_elem = (Element)parent_node.getOwnerDocument().importNode(new_elem, true);
-		if (start_from_elem == null) {
+	public static Element insertIntoOrderedList(Element parent_node, String node_name, Element start_from_elem, Element new_elem, String sort_att, boolean descending)
+	{
+		if (new_elem == null)
+			return null;
+		Element cloned_elem = (Element) parent_node.getOwnerDocument().importNode(new_elem, true);
+		if (start_from_elem == null)
+		{
 			parent_node.appendChild(cloned_elem);
 			return cloned_elem;
 		}
-		
+
 		Node current_node = start_from_elem;
 		String insert_att = cloned_elem.getAttribute(sort_att);
 		String list_att = start_from_elem.getAttribute(sort_att);
-		while ((!descending && list_att.compareTo(insert_att)<0) || (descending && list_att.compareTo(insert_att)>0)) {
+		while ((!descending && list_att.compareTo(insert_att) < 0) || (descending && list_att.compareTo(insert_att) > 0))
+		{
 			current_node = current_node.getNextSibling();
-			if (current_node == null) break; // end of the list
-			if (!current_node.getNodeName().equals(node_name)) {
+			if (current_node == null)
+				break; // end of the list
+			if (!current_node.getNodeName().equals(node_name))
+			{
 				continue; // not a valid node
 			}
-			list_att = ((Element)current_node).getAttribute(sort_att);
-		}
-		
+			list_att = ((Element) current_node).getAttribute(sort_att);
+		}
+
 		parent_node.insertBefore(cloned_elem, current_node);
 		return cloned_elem;
 	}
 
-
-	/** Returns the appropriate language element from a display elem,
-* display is the containing element, name is the name of the element to
-* look for, lang is the preferred language, lang_default is the fall back
-* lang if neither lang is found, will return the first one it finds*/
-	public static String getDisplayText(Element display, String name,
-	String lang, String lang_default) {
-		
+	/**
+	 * Returns the appropriate language element from a display elem, display is
+	 * the containing element, name is the name of the element to look for, lang
+	 * is the preferred language, lang_default is the fall back lang if neither
+	 * lang is found, will return the first one it finds
+	 */
+	public static String getDisplayText(Element display, String name, String lang, String lang_default)
+	{
+
 		String def = null;
 		String first = null;
 		NodeList elems = display.getElementsByTagName(DISPLAY_TEXT_ELEM);
-		if (elems.getLength() == 0) return "";
-		for (int i=0; i<elems.getLength(); i++) {
-			Element e = (Element)elems.item(i);
+		if (elems.getLength() == 0)
+			return "";
+		for (int i = 0; i < elems.getLength(); i++)
+		{
+			Element e = (Element) elems.item(i);
 			String n = e.getAttribute(NAME_ATT);
-			if (name.equals(n)) {
+			if (name.equals(n))
+			{
 				String l = e.getAttribute(LANG_ATT);
-				if (lang.equals(l)) {
+				if (lang.equals(l))
+				{
 					return getNodeText(e);
-				} else if (lang_default.equals(l)) {
+				}
+				else if (lang_default.equals(l))
+				{
 					def = getNodeText(e);
-				} else if (first == null) {
+				}
+				else if (first == null)
+				{
 					first = getNodeText(e);
 				}
-			} else {
+			}
+			else
+			{
 				continue;
 			}
 		}
-		
-		if (def != null) {
+
+		if (def != null)
+		{
 			return def;
 		}
-		if (first != null) {
+		if (first != null)
+		{
 			return first;
 		}
@@ -887,21 +986,34 @@
 
 	// replaces < > " ' & in the original with their entities
-	public static String xmlSafe(String original) {
-		
+	public static String xmlSafe(String original)
+	{
+
 		StringBuffer filtered = new StringBuffer(original.length());
 		char c;
-		for (int i=0; i<original.length(); i++) {
+		for (int i = 0; i < original.length(); i++)
+		{
 			c = original.charAt(i);
-			if (c == '>') {
+			if (c == '>')
+			{
 				filtered.append("&gt;");
-			} else if (c == '<') {
+			}
+			else if (c == '<')
+			{
 				filtered.append("&lt;");
-			} else if (c == '"') {
+			}
+			else if (c == '"')
+			{
 				filtered.append("&quot;");
-			} else if (c == '&') {
+			}
+			else if (c == '&')
+			{
 				filtered.append("&amp;");
-			} else if (c == '\'') {
+			}
+			else if (c == '\'')
+			{
 				filtered.append("&apos;");
-			} else {
+			}
+			else
+			{
 				filtered.append(c);
 			}
@@ -910,30 +1022,45 @@
 	}
 
-
 	// replaces < > " ' & entities with their originals
-	public static String unXmlSafe(String original) {
-		
+	public static String unXmlSafe(String original)
+	{
+
 		StringBuffer filtered = new StringBuffer(original.length());
 		char c;
-		for (int i=0; i<original.length(); i++) {
+		for (int i = 0; i < original.length(); i++)
+		{
 			c = original.charAt(i);
-			if (c == '&') {
+			if (c == '&')
+			{
 				int pos = original.indexOf(";", i);
-				String entity = original.substring(i+1, pos);
-				if (entity.equals("gt")) {
+				String entity = original.substring(i + 1, pos);
+				if (entity.equals("gt"))
+				{
 					filtered.append(">");
-				} else if (entity.equals("lt")) {
+				}
+				else if (entity.equals("lt"))
+				{
 					filtered.append("<");
-				} else if (entity.equals("apos")) {
+				}
+				else if (entity.equals("apos"))
+				{
 					filtered.append("'");
-				} else if (entity.equals("amp")) {
+				}
+				else if (entity.equals("amp"))
+				{
 					filtered.append("&");
-				} else if (entity.equals("quot")) {
+				}
+				else if (entity.equals("quot"))
+				{
 					filtered.append("\"");
-				} else {
-					filtered.append("&"+entity+";");
+				}
+				else
+				{
+					filtered.append("&" + entity + ";");
 				}
 				i = pos;
-			} else {
+			}
+			else
+			{
 				filtered.append(c);
 			}
@@ -942,27 +1069,32 @@
 	}
 
-	public static void printXMLNode(Node e, boolean printText) {
-		printXMLNode(e, 0, printText) ;
-	}
-
-	public static String xmlNodeToString(Node e){
+	public static void printXMLNode(Node e, boolean printText)
+	{
+		printXMLNode(e, 0, printText);
+	}
+
+	public static String xmlNodeToString(Node e)
+	{
 		StringBuffer sb = new StringBuffer("");
-		xmlNodeToString(sb,e,0,true);
+		xmlNodeToString(sb, e, 0, true);
 		return sb.toString();
 	}
 
-	public static String xmlNodeToString(Node e, boolean printText){
+	public static String xmlNodeToString(Node e, boolean printText)
+	{
 		StringBuffer sb = new StringBuffer("");
-		xmlNodeToString(sb,e,0,printText);
+		xmlNodeToString(sb, e, 0, printText);
 		return sb.toString();
 	}
 
-	private static void xmlNodeToString(StringBuffer sb, Node e, int depth, boolean printText){
-		
-		for (int i=0 ; i<depth ; i++)
-		sb.append(' ') ;
-		
-		if (e.getNodeType() == Node.TEXT_NODE){
-			if(printText)
+	private static void xmlNodeToString(StringBuffer sb, Node e, int depth, boolean printText)
+	{
+
+		for (int i = 0; i < depth; i++)
+			sb.append(' ');
+
+		if (e.getNodeType() == Node.TEXT_NODE)
+		{
+			if (printText)
 			{
 				sb.append(e.getNodeValue());
@@ -972,13 +1104,14 @@
 				sb.append("text");
 			}
-			return ;
-		}
-		
+			return;
+		}
+
 		sb.append('<');
 		sb.append(e.getNodeName());
 		NamedNodeMap attrs = e.getAttributes();
-		if(attrs != null)
-		{
-			for (int i = 0; i < attrs.getLength(); i++) {
+		if (attrs != null)
+		{
+			for (int i = 0; i < attrs.getLength(); i++)
+			{
 				Node attr = attrs.item(i);
 				sb.append(' ');
@@ -989,51 +1122,60 @@
 			}
 		}
-		
+
 		NodeList children = e.getChildNodes();
-		
+
 		if (children == null || children.getLength() == 0)
-		sb.append("/>\n") ;
-		else {
-			
-			sb.append(">\n") ;
-			
+			sb.append("/>\n");
+		else
+		{
+
+			sb.append(">\n");
+
 			int len = children.getLength();
-			for (int i = 0; i < len; i++) {
-				xmlNodeToString(sb,children.item(i), depth + 1, printText);
-			}
-			
-			for (int i=0 ; i<depth ; i++)
-			sb.append(' ') ;
-			
+			for (int i = 0; i < len; i++)
+			{
+				xmlNodeToString(sb, children.item(i), depth + 1, printText);
+			}
+
+			for (int i = 0; i < depth; i++)
+				sb.append(' ');
+
 			sb.append("</" + e.getNodeName() + ">\n");
 		}
-		
-		
-	}
-
-	public static void printXMLNode(Node e, int depth, boolean printText) { //recursive method call using DOM API...
-		
-		if(e == null){return;}
-		
-		for (int i=0 ; i<depth ; i++)
-		System.out.print(' ') ;
-		
-		if (e.getNodeType() == Node.TEXT_NODE){
-			if(printText){
+
+	}
+
+	public static void printXMLNode(Node e, int depth, boolean printText)
+	{ //recursive method call using DOM API...
+
+		if (e == null)
+		{
+			return;
+		}
+
+		for (int i = 0; i < depth; i++)
+			System.out.print(' ');
+
+		if (e.getNodeType() == Node.TEXT_NODE)
+		{
+			if (printText)
+			{
 				System.out.println(e.getNodeValue());
 			}
-			else {
+			else
+			{
 				System.out.println("text");
 			}
-			return ;
-		}
-		
+			return;
+		}
+
 		System.out.print('<');
 		System.out.print(e.getNodeName());
 		NamedNodeMap attrs = e.getAttributes();
-		
+
 		if (attrs != null)
 		{
-			for (int i = 0; i < attrs.getLength(); i++) {
+			for (int i = 0; i < attrs.getLength(); i++)
+			{
 				Node attr = attrs.item(i);
 				System.out.print(' ');
@@ -1044,34 +1186,40 @@
 			}
 		}
-		
+
 		NodeList children = e.getChildNodes();
-		
+
 		if (children == null || children.getLength() == 0)
-		System.out.println("/>") ;
-		else {
-			
-			System.out.println('>') ;
-			
+			System.out.println("/>");
+		else
+		{
+
+			System.out.println('>');
+
 			int len = children.getLength();
-			for (int i = 0; i < len; i++) {
+			for (int i = 0; i < len; i++)
+			{
 				printXMLNode(children.item(i), depth + 1, printText);
 			}
-			
-			for (int i=0 ; i<depth ; i++)
-			System.out.print(' ') ;
-			
+
+			for (int i = 0; i < depth; i++)
+				System.out.print(' ');
+
 			System.out.println("</" + e.getNodeName() + ">");
-		}	
-	}
-
-	public static void elementToLogAsString(Element e) {
-		try {
+		}
+	}
+
+	public static void elementToLogAsString(Element e)
+	{
+		try
+		{
 			TransformerFactory tf = TransformerFactory.newInstance();
 			Transformer trans = tf.newTransformer();
 			StringWriter sw = new StringWriter();
 			trans.transform(new DOMSource(e), new StreamResult(sw));
-			System.err.println( sw.toString() );
-		} catch( Exception ex ) {
-			System.err.println( "couldn't write " + e + " to log" );
+			System.err.println(sw.toString());
+		}
+		catch (Exception ex)
+		{
+			System.err.println("couldn't write " + e + " to log");
 		}
 	}
