Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java	(revision 28382)
@@ -24,6 +24,6 @@
 	/** the system set up variables */
 	protected HashMap<String, Object> config_params = null;
-	/** container Document to create XML Nodes */
-	protected Document doc = null;
+	
+	
 	/** a converter class to parse XML and create Docs */
 	protected XMLConverter converter = null;
@@ -39,5 +39,4 @@
 	{
 		this.converter = new XMLConverter();
-		this.doc = this.converter.newDOM();
 	}
 
@@ -193,7 +192,7 @@
 	}
 
-	protected Element createMetadataParamList(HashSet<String> metadata_names)
-	{
-		Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+	protected Element createMetadataParamList(Document doc, HashSet<String> metadata_names)
+	{
+		Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 
 		Element param = null;
@@ -202,5 +201,5 @@
 		{
 			String name = i.next();
-			param = this.doc.createElement(GSXML.PARAM_ELEM);
+			param = doc.createElement(GSXML.PARAM_ELEM);
 			param_list.appendChild(param);
 			param.setAttribute(GSXML.NAME_ATT, "metadata");
@@ -240,16 +239,18 @@
 	protected void addSiteMetadata(Element element, UserContext userContext)
 	{
+		Document doc = element.getOwnerDocument();
+		
 		//ADD SITE METADATA
-		Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
+		Element metadata_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
 		//create a hashmap of params
 		HashMap subset_params = new HashMap(1);
 		subset_params.put(GSXML.SUBSET_PARAM, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
 		//create the element to put the params in
-		Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		//put them in
-		GSXML.addParametersToList(this.doc, param_list, subset_params);
+		GSXML.addParametersToList(doc, param_list, subset_params);
 		metadata_request.appendChild(param_list);
 		//create the message
-		Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
 		metadata_message.appendChild(metadata_request);
 		//get response
@@ -263,8 +264,10 @@
 	protected void addInterfaceOptions(Element elem)
 	{
-		Element documentOptionList = this.doc.createElement("interfaceOptions");
+		Document doc = elem.getOwnerDocument();
+		
+		Element documentOptionList = doc.createElement("interfaceOptions");
 		for (Object key : this.config_params.keySet())
 		{
-			Element option = this.doc.createElement("option");
+			Element option = doc.createElement("option");
 			option.setAttribute(GSXML.NAME_ATT, (String) key);
 			option.setAttribute(GSXML.VALUE_ATT, this.config_params.get(key).toString());
@@ -276,6 +279,15 @@
 	protected Element getFormatInfo(String to, UserContext userContext)
 	{
-		Element mr_format_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
+		// Eclipse call hierarchy shows the element returned from this method is 
+		// subsequently used in a 'importNode'.  For this reason it is safe here
+		// for call up our own document DOM.  
+		//
+		// If this pattern changes for any reason, then the DOM will need to be
+		// passed in as a parameter
+		
+		Document doc = this.converter.newDOM();
+		
+		Element mr_format_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
 		mr_format_message.appendChild(mr_format_request);
 
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/AppletAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/AppletAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/AppletAction.java	(revision 28382)
@@ -25,8 +25,9 @@
 
 		Element message = this.converter.nodeToElement(message_node);
-
+		Document doc = message.getOwnerDocument();
+		
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 		result.appendChild(page_response);
 
@@ -62,9 +63,9 @@
 			// we are processing stuff for the applet send a message to the service, type="query", and take out the something element, and return that as our result - the applet must take xml
 
-			Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-			Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+			Element mr_message = doc.createElement(GSXML.MESSAGE_ELEM);
+			Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 			mr_message.appendChild(mr_request);
 			// just append all the params for now - should filter out unneeded ones
-			mr_request.appendChild(this.doc.importNode(cgi_param_list, true));
+			mr_request.appendChild(doc.importNode(cgi_param_list, true));
 
 			// process the request
@@ -80,6 +81,6 @@
 		// get the applet description, and the collection info if a collection is specified
 
-		Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element applet_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
+		Element mr_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element applet_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		mr_message.appendChild(applet_request);
 
@@ -89,5 +90,5 @@
 		String path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.SERVICE_ELEM);
 		//path = GSPath.appendLink(path, GSXML.APPLET_ELEM);
-		Element service_elem = (Element) this.doc.importNode(GSXML.getNodeByPath(mr_response, path), true);
+		Element service_elem = (Element) doc.importNode(GSXML.getNodeByPath(mr_response, path), true);
 		Element applet_elem = (Element) GSXML.getChildByTagName(service_elem, GSXML.APPLET_ELEM);
 		// must handle any params that have values that are not 
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/BrowseAction.java	(revision 28382)
@@ -12,4 +12,5 @@
 import org.greenstone.gsdl3.util.OID;
 import org.greenstone.gsdl3.util.UserContext;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -29,12 +30,12 @@
 	public Node process(Node message_node)
 	{
-
 		Element message = this.converter.nodeToElement(message_node);
-
+		Document doc = message.getOwnerDocument();
+		
 		// get the request - assume only one
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
 
 		// the result
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
 		Element response = classifierBrowse(request);
 		result.appendChild(response);
@@ -44,6 +45,7 @@
 	protected Element classifierBrowse(Element request)
 	{
-
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Document doc = request.getOwnerDocument();
+		
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 
 		// extract the params from the cgi-request, and check that we have a coll specified
@@ -75,10 +77,10 @@
 		// this should be cached somehow later on. 
 
-		Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
+		Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		info_message.appendChild(info_request);
 
 		// also get the format stuff now if there is some
-		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
+		Element format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
 		info_message.appendChild(format_request);
 		// process the requests
@@ -92,5 +94,5 @@
 
 		Element service_description = (Element) GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM);
-		page_response.appendChild(this.doc.importNode(service_description, true));
+		page_response.appendChild(doc.importNode(service_description, true));
 
 		//append site metadata
@@ -137,5 +139,5 @@
 					GSXSLT.mergeFormatElements(this_format, global_format_elem, false);
 				}
-				Element new_format = GSXML.duplicateWithNewName(this.doc, this_format, GSXML.FORMAT_ELEM, false);
+				Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
 				// set teh format type
 				new_format.setAttribute(GSXML.TYPE_ATT, "browse");
@@ -158,17 +160,17 @@
 		logger.info("extracted meta names, " + metadata_names.toString());
 		// get the browse structure for the selected node
-		Element classify_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element classify_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element classify_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element classify_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		classify_message.appendChild(classify_request);
 
 		//Create a parameter list to specify the required structure information
 		// for now, always get ancestors and children
-		Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		classify_request.appendChild(param_list);
-		Element param = this.doc.createElement(GSXML.PARAM_ELEM);
+		Element param = doc.createElement(GSXML.PARAM_ELEM);
 		param_list.appendChild(param);
 		param.setAttribute(GSXML.NAME_ATT, "structure");
 		param.setAttribute(GSXML.VALUE_ATT, "ancestors");
-		param = this.doc.createElement(GSXML.PARAM_ELEM);
+		param = doc.createElement(GSXML.PARAM_ELEM);
 		param_list.appendChild(param);
 		param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -176,5 +178,5 @@
 		if (get_siblings)
 		{
-			param = this.doc.createElement(GSXML.PARAM_ELEM);
+			param = doc.createElement(GSXML.PARAM_ELEM);
 			param_list.appendChild(param);
 			param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -183,6 +185,6 @@
 
 		// put the classifier node into a classifier node list
-		Element classifier_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
-		Element classifier = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
+		Element classifier_list = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element classifier = doc.createElement(GSXML.CLASS_NODE_ELEM);
 		classifier.setAttribute(GSXML.NODE_ID_ATT, classifier_node);
 		classifier_list.appendChild(classifier);
@@ -205,5 +207,5 @@
 
 		// add the classifier node as the page classifier 
-		Element page_classifier = GSXML.duplicateWithNewName(this.doc, cl_structure, GSXML.CLASSIFIER_ELEM, true);
+		Element page_classifier = GSXML.duplicateWithNewName(doc, cl_structure, GSXML.CLASSIFIER_ELEM, true);
 		page_response.appendChild(page_classifier);
 		page_classifier.setAttribute(GSXML.NAME_ATT, top_id);
@@ -212,5 +214,5 @@
 		// then for each document node
 
-		Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
 
 		boolean did_classifier = false;
@@ -225,8 +227,8 @@
 		{
 			did_classifier = true;
-			Element cl_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
+			Element cl_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
 			metadata_message.appendChild(cl_meta_request);
 
-			Element new_cl_nodes_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
+			Element new_cl_nodes_list = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
 			cl_meta_request.appendChild(new_cl_nodes_list);
 
@@ -234,5 +236,5 @@
 			{
 
-				Element cl = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
+				Element cl = doc.createElement(GSXML.CLASS_NODE_ELEM);
 				cl.setAttribute(GSXML.NODE_ID_ATT, ((Element) cl_nodes.item(c)).getAttribute(GSXML.NODE_ID_ATT));
 				new_cl_nodes_list.appendChild(cl);
@@ -245,6 +247,6 @@
 			if (metadata_names.isEmpty())
 			{
-				cl_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-				Element p = this.doc.createElement(GSXML.PARAM_ELEM);
+				cl_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+				Element p = doc.createElement(GSXML.PARAM_ELEM);
 				cl_param_list.appendChild(p);
 				p.setAttribute(GSXML.NAME_ATT, "metadata");
@@ -253,5 +255,5 @@
 			else
 			{
-				cl_param_list = createMetadataParamList(metadata_names);
+				cl_param_list = createMetadataParamList(doc,metadata_names);
 			}
 
@@ -267,8 +269,8 @@
 		{
 			did_documents = true;
-			Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
+			Element doc_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
 			metadata_message.appendChild(doc_meta_request);
 
-			Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+			Element doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 			doc_meta_request.appendChild(doc_list);
 
@@ -276,5 +278,5 @@
 			{
 
-				Element d = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+				Element d = doc.createElement(GSXML.DOC_NODE_ELEM);
 				d.setAttribute(GSXML.NODE_ID_ATT, ((Element) doc_nodes.item(c)).getAttribute(GSXML.NODE_ID_ATT));
 				doc_list.appendChild(d);
@@ -282,6 +284,6 @@
 
 			// create and add in the param list - add all for now
-			Element doc_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-			Element p = this.doc.createElement(GSXML.PARAM_ELEM);
+			Element doc_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+			Element p = doc.createElement(GSXML.PARAM_ELEM);
 			doc_param_list.appendChild(p);
 			p.setAttribute(GSXML.NAME_ATT, "metadata");
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DepositorAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DepositorAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DepositorAction.java	(revision 28382)
@@ -43,10 +43,11 @@
 	{
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
-
+		Document doc = request.getOwnerDocument();
+		
 		UserContext uc = new UserContext((Element) request);
 		String currentUsername = uc.getUsername();
 
-		Element responseMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element response = GSXML.createBasicResponse(this.doc, this.getClass().getSimpleName());
+		Element responseMessage = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element response = GSXML.createBasicResponse(doc, this.getClass().getSimpleName());
 		responseMessage.appendChild(response);
 
@@ -226,5 +227,5 @@
 			formContainer.appendChild(callToPage);
 
-			Element cachedValueElement = this.doc.createElement("cachedValues");
+			Element cachedValueElement = doc.createElement("cachedValues");
 			response.appendChild(cachedValueElement);
 			try
@@ -232,10 +233,10 @@
 				for (int i = pageNum; i > 0; i--)
 				{
-					Element page = this.doc.createElement("pageCache");
+					Element page = doc.createElement("pageCache");
 					page.setAttribute("pageNum", "" + i);
 					String cachedValues = database.getUserData(currentUsername, "DE___" + collection + "___" + i + "___CACHED_VALUES");
 					if (cachedValues != null)
 					{
-						page.appendChild(this.doc.createTextNode(cachedValues));
+						page.appendChild(doc.createTextNode(cachedValues));
 						cachedValueElement.appendChild(page);
 					}
@@ -287,5 +288,5 @@
 				{
 					ex.printStackTrace();
-					GSXML.addError(this.doc, responseMessage, "Failed to copy the deposited file into the collection.");
+					GSXML.addError(doc, responseMessage, "Failed to copy the deposited file into the collection.");
 					return responseMessage;
 				}
@@ -331,17 +332,17 @@
 				}
 
-				Element buildMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
-				Element buildRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, "ImportCollection", uc);
+				Element buildMessage = doc.createElement(GSXML.MESSAGE_ELEM);
+				Element buildRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, "ImportCollection", uc);
 				buildMessage.appendChild(buildRequest);
 
-				Element paramListElem = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+				Element paramListElem = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 				buildRequest.appendChild(paramListElem);
 
-				Element collectionParam = this.doc.createElement(GSXML.PARAM_ELEM);
+				Element collectionParam = doc.createElement(GSXML.PARAM_ELEM);
 				paramListElem.appendChild(collectionParam);
 				collectionParam.setAttribute(GSXML.NAME_ATT, GSXML.COLLECTION_ATT);
 				collectionParam.setAttribute(GSXML.VALUE_ATT, collection);
 
-				Element documentsParam = this.doc.createElement(GSXML.PARAM_ELEM);
+				Element documentsParam = doc.createElement(GSXML.PARAM_ELEM);
 				paramListElem.appendChild(documentsParam);
 				documentsParam.setAttribute(GSXML.NAME_ATT, "documents");
@@ -350,5 +351,5 @@
 				Element buildResponseMessage = (Element) this.mr.process(buildMessage);
 
-				response.appendChild(this.doc.importNode(buildResponseMessage, true));
+				response.appendChild(doc.importNode(buildResponseMessage, true));
 			}
 		}
@@ -364,9 +365,9 @@
 		else
 		{
-			Element depositorPage = this.doc.createElement("depositorPage");
+			Element depositorPage = doc.createElement("depositorPage");
 			response.appendChild(depositorPage);
 
-			Element collList = getCollectionsInSite();
-			depositorPage.appendChild(this.doc.importNode(collList, true));
+			Element collList = getCollectionsInSite(doc);
+			depositorPage.appendChild(doc.importNode(collList, true));
 		}
 
@@ -374,8 +375,8 @@
 	}
 
-	public Element getCollectionsInSite()
+	public Element getCollectionsInSite(Document doc) 
 	{
-		Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext());
+		Element message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", new UserContext());
 		message.appendChild(request);
 		Element responseMessage = (Element) this.mr.process(message);
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/DocumentAction.java	(revision 28382)
@@ -82,8 +82,9 @@
 
 		Element message = this.converter.nodeToElement(message_node);
-
+		Document doc = message.getOwnerDocument();
+		
 		// the response
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 		result.appendChild(page_response);
 
@@ -174,10 +175,10 @@
 		// the_document is where all the doc info - structure and metadata etc
 		// is added into, to be returned in the page
-		Element the_document = this.doc.createElement(GSXML.DOCUMENT_ELEM);
+		Element the_document = doc.createElement(GSXML.DOCUMENT_ELEM);
 		page_response.appendChild(the_document);
 
 		// create a basic doc list containing the current node
-		Element basic_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
-		Element current_doc = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+		Element basic_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element current_doc = doc.createElement(GSXML.DOC_NODE_ELEM);
 		basic_doc_list.appendChild(current_doc);
 		if (document_id != null)
@@ -207,9 +208,9 @@
 
 		// Create a parameter list to specify the required structure information
-		Element ds_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element ds_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 
 		if (service_params != null)
 		{
-			GSXML.addParametersToList(this.doc, ds_param_list, service_params);
+			GSXML.addParametersToList(doc, ds_param_list, service_params);
 		}
 
@@ -223,5 +224,5 @@
 			if (expand_contents)
 			{
-				ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+				ds_param = doc.createElement(GSXML.PARAM_ELEM);
 				ds_param_list.appendChild(ds_param);
 				ds_param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -230,13 +231,13 @@
 
 			// get the info needed for paged naviagtion
-			ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+			ds_param = doc.createElement(GSXML.PARAM_ELEM);
 			ds_param_list.appendChild(ds_param);
 			ds_param.setAttribute(GSXML.NAME_ATT, "info");
 			ds_param.setAttribute(GSXML.VALUE_ATT, "numSiblings");
-			ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+			ds_param = doc.createElement(GSXML.PARAM_ELEM);
 			ds_param_list.appendChild(ds_param);
 			ds_param.setAttribute(GSXML.NAME_ATT, "info");
 			ds_param.setAttribute(GSXML.VALUE_ATT, "numChildren");
-			ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+			ds_param = doc.createElement(GSXML.PARAM_ELEM);
 			ds_param_list.appendChild(ds_param);
 			ds_param.setAttribute(GSXML.NAME_ATT, "info");
@@ -245,5 +246,5 @@
 			if (get_siblings)
 			{
-				ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+				ds_param = doc.createElement(GSXML.PARAM_ELEM);
 				ds_param_list.appendChild(ds_param);
 				ds_param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -257,5 +258,5 @@
 			if (expand_contents)
 			{
-				ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+				ds_param = doc.createElement(GSXML.PARAM_ELEM);
 				ds_param_list.appendChild(ds_param);
 				ds_param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -265,9 +266,9 @@
 			{
 				// get the info needed for table of contents
-				ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+				ds_param = doc.createElement(GSXML.PARAM_ELEM);
 				ds_param_list.appendChild(ds_param);
 				ds_param.setAttribute(GSXML.NAME_ATT, "structure");
 				ds_param.setAttribute(GSXML.VALUE_ATT, "ancestors");
-				ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+				ds_param = doc.createElement(GSXML.PARAM_ELEM);
 				ds_param_list.appendChild(ds_param);
 				ds_param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -275,5 +276,5 @@
 				if (get_siblings)
 				{
-					ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+					ds_param = doc.createElement(GSXML.PARAM_ELEM);
 					ds_param_list.appendChild(ds_param);
 					ds_param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -292,7 +293,7 @@
 
 			// Build a request to obtain the document structure
-			Element ds_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+			Element ds_message = doc.createElement(GSXML.MESSAGE_ELEM);
 			String to = GSPath.appendLink(collection, "DocumentStructureRetrieve");// Hard-wired?
-			Element ds_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+			Element ds_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 			ds_message.appendChild(ds_request);
 			ds_request.appendChild(ds_param_list);
@@ -316,5 +317,5 @@
 			if (ds_response_struct_info != null)
 			{
-				the_document.appendChild(this.doc.importNode(ds_response_struct_info, true));
+				the_document.appendChild(doc.importNode(ds_response_struct_info, true));
 			}
 			path = GSPath.appendLink(GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
@@ -329,5 +330,5 @@
 				for (int i = 0; i < structs.getLength(); i++)
 				{
-					the_document.appendChild(this.doc.importNode(structs.item(i), true));
+					the_document.appendChild(doc.importNode(structs.item(i), true));
 				}
 			}
@@ -335,5 +336,5 @@
 			{
 				// no structure nodes, so put in a dummy doc node
-				Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+				Element doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
 				if (document_id != null)
 				{
@@ -353,5 +354,5 @@
 			// should think about this more
 			// no structure request, so just put in a dummy doc node
-			Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+			Element doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
 			if (document_id != null)
 			{
@@ -367,7 +368,7 @@
 
 		// Build a request to obtain some document metadata
-		Element dm_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element dm_message = doc.createElement(GSXML.MESSAGE_ELEM);
 		String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired?
-		Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element dm_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		dm_message.appendChild(dm_request);
 		// Create a parameter list to specify the required metadata information
@@ -390,8 +391,8 @@
 		}
 
-		Element dm_param_list = createMetadataParamList(meta_names);
+		Element dm_param_list = createMetadataParamList(doc,meta_names);
 		if (service_params != null)
 		{
-			GSXML.addParametersToList(this.doc, dm_param_list, service_params);
+			GSXML.addParametersToList(doc, dm_param_list, service_params);
 		}
 
@@ -399,5 +400,5 @@
 
 		// create the doc node list for the metadata request
-		Element dm_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element dm_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 		dm_request.appendChild(dm_doc_list);
 
@@ -410,5 +411,5 @@
 
 			// Add the documentNode to the list
-			Element dm_doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+			Element dm_doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
 			dm_doc_list.appendChild(dm_doc_node);
 			dm_doc_node.setAttribute(GSXML.NODE_ID_ATT, doc_node_id);
@@ -418,14 +419,14 @@
 		// we also want a metadata request to the top level document to get
 		// assocfilepath - this could be cached too
-		Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element doc_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		dm_message.appendChild(doc_meta_request);
-		Element doc_meta_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element doc_meta_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		if (service_params != null)
 		{
-			GSXML.addParametersToList(this.doc, doc_meta_param_list, service_params);
+			GSXML.addParametersToList(doc, doc_meta_param_list, service_params);
 		}
 
 		doc_meta_request.appendChild(doc_meta_param_list);
-		Element doc_param = this.doc.createElement(GSXML.PARAM_ELEM);
+		Element doc_param = doc.createElement(GSXML.PARAM_ELEM);
 		doc_meta_param_list.appendChild(doc_param);
 		doc_param.setAttribute(GSXML.NAME_ATT, "metadata");
@@ -433,8 +434,8 @@
 
 		// create the doc node list for the metadata request
-		Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 		doc_meta_request.appendChild(doc_list);
 
-		Element doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+		Element doc_node = doc.createElement(GSXML.DOC_NODE_ELEM);
 		// the node we want is the root document node
 		if (document_id != null)
@@ -472,14 +473,14 @@
 
 		// Build a request to obtain some document content
-		Element dc_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element dc_message = doc.createElement(GSXML.MESSAGE_ELEM);
 		to = GSPath.appendLink(collection, "DocumentContentRetrieve"); // Hard-wired?
-		Element dc_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element dc_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		dc_message.appendChild(dc_request);
 
 		// Create a parameter list to specify the request parameters - empty for now
-		Element dc_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element dc_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		if (service_params != null)
 		{
-			GSXML.addParametersToList(this.doc, dc_param_list, service_params);
+			GSXML.addParametersToList(doc, dc_param_list, service_params);
 		}
 
@@ -518,5 +519,5 @@
 						content = highlightQueryTerms(request, (Element) content);
 					}
-					doc_nodes.item(i).appendChild(this.doc.importNode(content, true));
+					doc_nodes.item(i).appendChild(doc.importNode(content, true));
 				}
 				//GSXML.mergeMetadataLists(doc_nodes.item(i), dm_response_docs.item(i));
@@ -561,6 +562,6 @@
 					String enrich_service = (String) params.get(GSParams.SERVICE);
 					// send a message to the service
-					Element enrich_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-					Element enrich_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, enrich_service, userContext);
+					Element enrich_message = doc.createElement(GSXML.MESSAGE_ELEM);
+					Element enrich_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, enrich_service, userContext);
 					enrich_message.appendChild(enrich_request);
 					// check for parameters
@@ -568,11 +569,11 @@
 					if (e_service_params != null)
 					{
-						Element enrich_pl = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-						GSXML.addParametersToList(this.doc, enrich_pl, e_service_params);
+						Element enrich_pl = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+						GSXML.addParametersToList(doc, enrich_pl, e_service_params);
 						enrich_request.appendChild(enrich_pl);
 					}
-					Element e_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+					Element e_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 					enrich_request.appendChild(e_doc_list);
-					e_doc_list.appendChild(this.doc.importNode(dc_response_doc, true));
+					e_doc_list.appendChild(doc.importNode(dc_response_doc, true));
 
 					Node enrich_response = this.mr.process(enrich_message);
@@ -595,5 +596,5 @@
 
 				dummy_node.setAttribute(GSXML.NODE_ID_ATT, modified_doc_id);
-				dummy_node.appendChild(this.doc.importNode(dc_response_doc_content, true));
+				dummy_node.appendChild(doc.importNode(dc_response_doc_content, true));
 				// hack for simple type
 				if (document_type.equals(GSXML.DOC_TYPE_SIMPLE))
@@ -630,5 +631,5 @@
 					if (dn_id.equals(modified_doc_id))
 					{
-						dn.appendChild(this.doc.importNode(dc_response_doc_content, true));
+						dn.appendChild(doc.importNode(dc_response_doc_content, true));
 						break;
 					}
@@ -663,12 +664,13 @@
 	protected boolean getBackgroundData(Element page_response, String collection, UserContext userContext)
 	{
-
+		Document doc = page_response.getOwnerDocument();
+		
 		// create a message to process - contains requests for the collection 
 		// description, the format element, the enrich services on offer
 		// these could all be cached
-		Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
 		String path = GSPath.appendLink(collection, "DocumentContentRetrieve");
 		// the format request - ignore for now, where does this request go to??
-		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, path, userContext);
+		Element format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, path, userContext);
 		info_message.appendChild(format_request);
 
@@ -677,5 +679,5 @@
 		if (provide_annotations)
 		{
-			Element enrich_services_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
+			Element enrich_services_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
 			enrich_services_request.setAttribute(GSXML.INFO_ATT, "serviceList");
 			info_message.appendChild(enrich_services_request);
@@ -699,5 +701,5 @@
 			// set the format type
 			format_elem.setAttribute(GSXML.TYPE_ATT, "display");
-			page_response.appendChild(this.doc.importNode(format_elem, true));
+			page_response.appendChild(doc.importNode(format_elem, true));
 		}
 
@@ -707,5 +709,5 @@
 
 			// a new message for the mr
-			Element enrich_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+			Element enrich_message = doc.createElement(GSXML.MESSAGE_ELEM);
 			NodeList e_services = services_resp.getElementsByTagName(GSXML.SERVICE_ELEM);
 			boolean service_found = false;
@@ -714,5 +716,5 @@
 				if (((Element) e_services.item(j)).getAttribute(GSXML.TYPE_ATT).equals("enrich"))
 				{
-					Element s = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, ((Element) e_services.item(j)).getAttribute(GSXML.NAME_ATT), userContext);
+					Element s = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, ((Element) e_services.item(j)).getAttribute(GSXML.NAME_ATT), userContext);
 					enrich_message.appendChild(s);
 					service_found = true;
@@ -724,9 +726,9 @@
 
 				NodeList e_responses = enrich_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
-				Element service_list = this.doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
+				Element service_list = doc.createElement(GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
 				for (int i = 0; i < e_responses.getLength(); i++)
 				{
 					Element e_resp = (Element) e_responses.item(i);
-					Element e_service = (Element) this.doc.importNode(GSXML.getChildByTagName(e_resp, GSXML.SERVICE_ELEM), true);
+					Element e_service = (Element) doc.importNode(GSXML.getChildByTagName(e_resp, GSXML.SERVICE_ELEM), true);
 					e_service.setAttribute(GSXML.NAME_ATT, e_resp.getAttribute(GSXML.FROM_ATT));
 					service_list.appendChild(e_service);
@@ -741,12 +743,14 @@
 	protected String getDocumentType(Element basic_doc_list, String collection, UserContext userContext, Element page_response)
 	{
-		Element ds_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Document doc = basic_doc_list.getOwnerDocument();
+		
+		Element ds_message = doc.createElement(GSXML.MESSAGE_ELEM);
 		String to = GSPath.appendLink(collection, "DocumentStructureRetrieve");// Hard-wired?
-		Element ds_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element ds_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		ds_message.appendChild(ds_request);
 
 		// Create a parameter list to specify the required structure information
-		Element ds_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-		Element ds_param = this.doc.createElement(GSXML.PARAM_ELEM);
+		Element ds_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element ds_param = doc.createElement(GSXML.PARAM_ELEM);
 		ds_param_list.appendChild(ds_param);
 		ds_param.setAttribute(GSXML.NAME_ATT, "info");
@@ -787,4 +791,6 @@
 	protected Element highlightQueryTerms(Element request, Element dc_response_doc_content)
 	{
+		Document doc = request.getOwnerDocument();
+		
 		// do the query again to get term info 
 		Element cgi_param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -806,6 +812,6 @@
 		String to = GSPath.appendLink(collection, service_name);
 
-		Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_query_message.appendChild(mr_query_request);
 
@@ -813,6 +819,6 @@
 		HashMap service_params = (HashMap) params.get("s1");
 
-		Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-		GSXML.addParametersToList(this.doc, query_param_list, service_params);
+		Element query_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		GSXML.addParametersToList(doc, query_param_list, service_params);
 		mr_query_request.appendChild(query_param_list);
 
@@ -969,5 +975,5 @@
 		}
 
-		return highlightQueryTermsInternal(content, query_term_variants, phrase_query_term_variants_hierarchy);
+		return highlightQueryTermsInternal(doc, content, query_term_variants, phrase_query_term_variants_hierarchy);
 	}
 
@@ -975,5 +981,5 @@
 	 * Highlights query terms in a piece of text.
 	 */
-	private Element highlightQueryTermsInternal(String content, HashSet<String> query_term_variants, ArrayList<ArrayList<HashSet<String>>> phrase_query_term_variants_hierarchy)
+	private Element highlightQueryTermsInternal(Document doc, String content, HashSet<String> query_term_variants, ArrayList<ArrayList<HashSet<String>>> phrase_query_term_variants_hierarchy)
 	{
 		// Convert the content string to an array of characters for speed
@@ -1122,5 +1128,5 @@
 
 		// Now add the annotation tags into the document at the correct points
-		Element content_element = this.doc.createElement(GSXML.NODE_CONTENT_ELEM);
+		Element content_element = doc.createElement(GSXML.NODE_CONTENT_ELEM);
 
 		int last_wrote = 0;
@@ -1134,5 +1140,5 @@
 			{
 				String preceding_text = new String(content_characters, last_wrote, (highlight_start - last_wrote));
-				content_element.appendChild(this.doc.createTextNode(preceding_text));
+				content_element.appendChild(doc.createTextNode(preceding_text));
 			}
 
@@ -1141,5 +1147,5 @@
 			{
 				String highlight_text = new String(content_characters, highlight_start, (highlight_end - highlight_start));
-				Element annotation_element = GSXML.createTextElement(this.doc, "annotation", highlight_text);
+				Element annotation_element = GSXML.createTextElement(doc, "annotation", highlight_text);
 				annotation_element.setAttribute("type", "query_term");
 				content_element.appendChild(annotation_element);
@@ -1152,5 +1158,5 @@
 		{
 			String remaining_text = new String(content_characters, last_wrote, (content_characters.length - last_wrote));
-			content_element.appendChild(this.doc.createTextNode(remaining_text));
+			content_element.appendChild(doc.createTextNode(remaining_text));
 		}
 
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/FormatAction.java	(revision 28382)
@@ -41,5 +41,6 @@
 	
 	    Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
     	// assume only one request
 	    Element request = (Element)GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
@@ -51,5 +52,5 @@
 	    HashMap<String, Serializable> params = GSXML.extractParams(cgi_param_list, false);
 
-    	Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
+    	Element result = doc.createElement(GSXML.MESSAGE_ELEM);
 	
 	    String coll = (String)params.get(GSParams.COLLECTION); //SYSTEM_CLUSTER);
@@ -62,6 +63,6 @@
         }
 
-        Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-        Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, userContext);
+        Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
+        Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT_STRING, to, userContext);
 
         mr_request.setAttribute("service", service);
@@ -74,5 +75,5 @@
         String format_string = (String)params.get("data");
     
-        Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+        Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 
         Iterator<String> it = params.keySet().iterator();
@@ -80,5 +81,5 @@
         if(subaction.equals("saveDocument"))
         {
-            Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
+            Element format = doc.createElement(GSXML.FORMAT_STRING_ELEM);
             try{
                 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -88,5 +89,5 @@
                 Node n1 = d.getFirstChild();
 
-                Element format_statement = (Element) this.doc.importNode(n1, true);
+                Element format_statement = (Element) doc.importNode(n1, true);
                 format.appendChild(format_statement);
                 mr_request.appendChild(format);
@@ -126,6 +127,6 @@
                     transformed = ((Document)transformed).getDocumentElement(); 
 
-                Element format = this.doc.createElement(GSXML.FORMAT_STRING_ELEM);
-                format.appendChild(this.doc.importNode(transformed,true));
+                Element format = doc.createElement(GSXML.FORMAT_STRING_ELEM);
+                format.appendChild(doc.importNode(transformed,true));
                 mr_request.appendChild(format); 
                 logger.error("Transformed: "+transformed);
@@ -145,5 +146,5 @@
         Node response_message = this.mr.process(mr_request_message);
 	
-        result.appendChild(GSXML.duplicateWithNewName(this.doc, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true));
+        result.appendChild(GSXML.duplicateWithNewName(doc, (Element)GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true));
         return result;
 	
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GS2BrowseAction.java	(revision 28382)
@@ -12,4 +12,5 @@
 import org.greenstone.gsdl3.util.OID;
 import org.greenstone.gsdl3.util.UserContext;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -29,12 +30,12 @@
 	public Node process(Node message_node)
 	{
-
 		Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
 		// get the request - assume only one
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
 
 		// the result
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
 		Element response = classifierBrowse(request);
 		result.appendChild(response);
@@ -44,5 +45,6 @@
 	protected Element classifierBrowse(Element request)
 	{
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Document doc = request.getOwnerDocument();
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 
 		// extract the params from the cgi-request, and check that we have a coll specified
@@ -72,10 +74,10 @@
 		// this should be cached somehow later on. 
 
-		Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
+		Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		info_message.appendChild(info_request);
 
 		// also get the format stuff now if there is some
-		Element format_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
+		Element format_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, to, userContext);
 		info_message.appendChild(format_request);
 		// process the requests
@@ -89,5 +91,5 @@
 
 		Element service_description = (Element) GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM);
-		page_response.appendChild(this.doc.importNode(service_description, true));
+		page_response.appendChild(doc.importNode(service_description, true));
 
 		//append site metadata
@@ -139,5 +141,5 @@
 				}
 
-				Element new_format = GSXML.duplicateWithNewName(this.doc, this_format, GSXML.FORMAT_ELEM, false);
+				Element new_format = GSXML.duplicateWithNewName(doc, this_format, GSXML.FORMAT_ELEM, false);
 				extractMetadataNames(new_format, doc_meta_names, class_meta_names);
 
@@ -164,17 +166,17 @@
 
 		// get the browse structure for the selected node
-		Element classify_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element classify_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element classify_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element classify_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		classify_message.appendChild(classify_request);
 
 		//Create a parameter list to specify the required structure information
 		// for now, always get ancestors and children
-		Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		classify_request.appendChild(param_list);
-		Element param = this.doc.createElement(GSXML.PARAM_ELEM);
+		Element param = doc.createElement(GSXML.PARAM_ELEM);
 		param_list.appendChild(param);
 		param.setAttribute(GSXML.NAME_ATT, "structure");
 		param.setAttribute(GSXML.VALUE_ATT, "ancestors");
-		param = this.doc.createElement(GSXML.PARAM_ELEM);
+		param = doc.createElement(GSXML.PARAM_ELEM);
 		param_list.appendChild(param);
 		param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -183,5 +185,5 @@
 		if (get_descendants)
 		{
-			param = this.doc.createElement(GSXML.PARAM_ELEM);
+			param = doc.createElement(GSXML.PARAM_ELEM);
 			param_list.appendChild(param);
 			param.setAttribute(GSXML.NAME_ATT, "structure");
@@ -191,6 +193,6 @@
 
 		// put the classifier node into a classifier node list
-		Element classifier_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
-		Element classifier = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
+		Element classifier_list = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element classifier = doc.createElement(GSXML.CLASS_NODE_ELEM);
 		classifier.setAttribute(GSXML.NODE_ID_ATT, classifier_node);
 		classifier_list.appendChild(classifier);
@@ -233,5 +235,5 @@
 				if (firstChildIsClassifierNode)
 				{
-					Element childStructure = getClassifierStructureFromID(classifier_node + ".1", request, collection, service_name);
+					Element childStructure = getClassifierStructureFromID(doc, classifier_node + ".1", request, collection, service_name);
 
 					Element replacementElem = null;
@@ -266,5 +268,5 @@
 			else
 			{
-				Element childStructure = getClassifierStructureFromID(OID.getTop(classifier_node), request, collection, service_name);
+				Element childStructure = getClassifierStructureFromID(doc, OID.getTop(classifier_node), request, collection, service_name);
 
 				String[] idParts = classifier_node.split("\\.");
@@ -305,5 +307,5 @@
 		Element page_classifier = null;
 		// add the single classifier node as the page classifier 
-		page_classifier = GSXML.duplicateWithNewName(this.doc, cl_structure, GSXML.CLASSIFIER_ELEM, true);
+		page_classifier = GSXML.duplicateWithNewName(doc, cl_structure, GSXML.CLASSIFIER_ELEM, true);
 		page_response.appendChild(page_classifier);
 		page_classifier.setAttribute(GSXML.NAME_ATT, top_id);
@@ -312,5 +314,5 @@
 		// then for each document node
 
-		Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
 
 		boolean did_classifier = false;
@@ -325,8 +327,8 @@
 		{
 			did_classifier = true;
-			Element cl_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
+			Element cl_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to + "MetadataRetrieve", userContext);
 			metadata_message.appendChild(cl_meta_request);
 
-			Element new_cl_nodes_list = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
+			Element new_cl_nodes_list = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
 			cl_meta_request.appendChild(new_cl_nodes_list);
 
@@ -334,5 +336,5 @@
 			{
 
-				Element cl = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
+				Element cl = doc.createElement(GSXML.CLASS_NODE_ELEM);
 				cl.setAttribute(GSXML.NODE_ID_ATT, ((Element) cl_nodes.item(c)).getAttribute(GSXML.NODE_ID_ATT));
 				new_cl_nodes_list.appendChild(cl);
@@ -342,5 +344,5 @@
 			// should be based on info sent in from the recept, and the 
 			// format stuff
-			Element cl_param_list = createMetadataParamList(class_meta_names);
+			Element cl_param_list = createMetadataParamList(doc,class_meta_names);
 			cl_meta_request.appendChild(cl_param_list);
 
@@ -354,8 +356,8 @@
 		{
 			did_documents = true;
-			Element doc_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
+			Element doc_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), userContext);
 			metadata_message.appendChild(doc_meta_request);
 
-			Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+			Element doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 			doc_meta_request.appendChild(doc_list);
 
@@ -363,5 +365,5 @@
 			{
 
-				Element d = this.doc.createElement(GSXML.DOC_NODE_ELEM);
+				Element d = doc.createElement(GSXML.DOC_NODE_ELEM);
 				d.setAttribute(GSXML.NODE_ID_ATT, ((Element) doc_nodes.item(c)).getAttribute(GSXML.NODE_ID_ATT));
 				doc_list.appendChild(d);
@@ -369,5 +371,5 @@
 
 			// create and add in the param list - add all for now
-			Element doc_param_list = createMetadataParamList(doc_meta_names);
+			Element doc_param_list = createMetadataParamList(doc,doc_meta_names);
 			doc_meta_request.appendChild(doc_param_list);
 
@@ -431,28 +433,28 @@
 	}
 
-	private Element getClassifierStructureFromID(String id, Element request, String collection, String service_name)
+	private Element getClassifierStructureFromID(Document doc, String id, Element request, String collection, String service_name)
 	{
 		UserContext userContext = new UserContext(request);
 		String to = GSPath.appendLink(collection, service_name);
 
-		Element firstClassifierNodeChildrenMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element firstClassifierNodeChildrenRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element firstClassifierNodeChildrenMessage = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element firstClassifierNodeChildrenRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		firstClassifierNodeChildrenMessage.appendChild(firstClassifierNodeChildrenRequest);
 
-		Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element paramList = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		firstClassifierNodeChildrenRequest.appendChild(paramList);
 
-		Element ancestorParam = this.doc.createElement(GSXML.PARAM_ELEM);
+		Element ancestorParam = doc.createElement(GSXML.PARAM_ELEM);
 		paramList.appendChild(ancestorParam);
 		ancestorParam.setAttribute(GSXML.NAME_ATT, "structure");
 		ancestorParam.setAttribute(GSXML.VALUE_ATT, "ancestors");
 
-		Element childrenParam = this.doc.createElement(GSXML.PARAM_ELEM);
+		Element childrenParam = doc.createElement(GSXML.PARAM_ELEM);
 		paramList.appendChild(childrenParam);
 		childrenParam.setAttribute(GSXML.NAME_ATT, "structure");
 		childrenParam.setAttribute(GSXML.VALUE_ATT, "children");
 
-		Element classifierToGetList = this.doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
-		Element classifierToGet = this.doc.createElement(GSXML.CLASS_NODE_ELEM);
+		Element classifierToGetList = doc.createElement(GSXML.CLASS_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element classifierToGet = doc.createElement(GSXML.CLASS_NODE_ELEM);
 		classifierToGet.setAttribute(GSXML.NODE_ID_ATT, id);
 		classifierToGetList.appendChild(classifierToGet);
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/GeneralAction.java	(revision 28382)
@@ -31,8 +31,9 @@
 	{
 		Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
 		// the result
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 		result.appendChild(page_response);
 
@@ -87,6 +88,6 @@
 		{
 			//do the request
-			Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-			Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+			Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
+			Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 
 			if (request_type.equals("s"))
@@ -102,6 +103,6 @@
 			if (service_params != null)
 			{
-				param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-				GSXML.addParametersToList(this.doc, param_list, service_params);
+				param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+				GSXML.addParametersToList(doc, param_list, service_params);
 				mr_query_request.appendChild(param_list);
 			}
@@ -110,5 +111,5 @@
 			if (userInformation != null)
 			{
-				mr_query_request.appendChild(this.doc.importNode(userInformation, true));
+				mr_query_request.appendChild(doc.importNode(userInformation, true));
 			}
 			mr_query_request.setAttribute("remoteAddress", request.getAttribute("remoteAddress"));
@@ -134,6 +135,6 @@
 
 		// request the service info for the selected service - should be cached
-		Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
+		Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		mr_info_message.appendChild(mr_info_request);
 		Element mr_info_response = (Element) this.mr.process(mr_info_message);
@@ -145,5 +146,5 @@
 		if (desNode != null)
 		{
-			page_response.appendChild((Element) this.doc.importNode(desNode, true));
+			page_response.appendChild((Element) doc.importNode(desNode, true));
 		}
 
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/NoCollQueryAction.java	(revision 28382)
@@ -38,13 +38,14 @@
 
 		Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
 		// get the request - assume there is only one
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
 
 		// create the return message
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
 		// for now we only have one type of query - subaction not used
 		Element response = basicQuery(request);
-		result.appendChild(this.doc.importNode(response, true));
+		result.appendChild(doc.importNode(response, true));
 		return result;
 	}
@@ -52,12 +53,13 @@
 	/**
 	 * a generic query handler this gets the service description, does the query
-	 * (just passes all teh params to the service, then gets the titles for any
+	 * (just passes all the params to the service, then gets the titles for any
 	 * results
 	 */
 	protected Element basicQuery(Element request)
 	{
-
 		// the result
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Document doc = request.getOwnerDocument();
+		
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 
 		// extract the params from the cgi-request, and check that we have a coll specified
@@ -72,6 +74,6 @@
 			// the only info we need to return is the collection list cos the xslt does teh rest
 
-			Element coll_list = getCollectionList(userContext);
-			page_response.appendChild(this.doc.importNode(coll_list, true));
+			Element coll_list = getCollectionList(doc, userContext);
+			page_response.appendChild(doc.importNode(coll_list, true));
 			return page_response;
 
@@ -89,6 +91,6 @@
 		{
 			logger.error("no collections were specified!");
-			Element coll_list = getCollectionList(userContext);
-			page_response.appendChild(this.doc.importNode(coll_list, true));
+			Element coll_list = getCollectionList(doc,userContext);
+			page_response.appendChild(doc.importNode(coll_list, true));
 			return page_response;
 		}
@@ -100,16 +102,16 @@
 			return page_response;
 		}
-		Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-		GSXML.addParametersToList(this.doc, query_param_list, service_params);
+		Element query_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		GSXML.addParametersToList(doc, query_param_list, service_params);
 
 		// we will do a query for each coll
 		String[] colls = query_coll_list.split(",");
 
-		Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
 
 		for (int i = 0; i < colls.length; i++)
 		{
 			String to = GSPath.appendLink(colls[i], service_name);
-			Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+			Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 			mr_query_message.appendChild(mr_query_request);
 			mr_query_request.appendChild(query_param_list.cloneNode(true));
@@ -121,5 +123,5 @@
 
 		// get the Title metadata for each node - need Node title and root title
-		Element mr_meta_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_meta_message = doc.createElement(GSXML.MESSAGE_ELEM);
 		NodeList responses = mr_query_response.getElementsByTagName(GSXML.RESPONSE_ELEM);
 		for (int j = 0; j < responses.getLength(); j++)
@@ -130,12 +132,12 @@
 				String coll_name = extractCollName(((Element) responses.item(j)).getAttribute(GSXML.FROM_ATT));
 				String path = GSPath.appendLink(coll_name, "DocumentMetadataRetrieve");
-				Element mr_meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, path, userContext);
+				Element mr_meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, path, userContext);
 				mr_meta_message.appendChild(mr_meta_request);
-				mr_meta_request.appendChild(this.doc.importNode(document_list, true));
+				mr_meta_request.appendChild(doc.importNode(document_list, true));
 				// metadata params 
-				Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-				Element param = GSXML.createParameter(this.doc, "metadata", "Title");
+				Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+				Element param = GSXML.createParameter(doc, "metadata", "Title");
 				param_list.appendChild(param);
-				param = GSXML.createParameter(this.doc, "metadata", "root_Title");
+				param = GSXML.createParameter(doc, "metadata", "root_Title");
 				param_list.appendChild(param);
 				mr_meta_request.appendChild(param_list);
@@ -148,5 +150,5 @@
 
 		// the result 
-		Element result_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element result_doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 		page_response.appendChild(result_doc_list);
 
@@ -182,10 +184,10 @@
 	}
 
-	protected Element getCollectionList(UserContext userContext)
+	protected Element getCollectionList(Document doc, UserContext userContext)
 	{
 
 		// first, get the message router info
-		Element coll_list_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
+		Element coll_list_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element coll_list_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
 		coll_list_message.appendChild(coll_list_request);
 		Element coll_list_response = (Element) this.mr.process(coll_list_message);
@@ -199,9 +201,9 @@
 		NodeList colls = coll_list_response.getElementsByTagName(GSXML.COLLECTION_ELEM);
 
-		Element coll_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-		Element param = GSXML.createParameter(this.doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
+		Element coll_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element param = GSXML.createParameter(doc, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
 		coll_param_list.appendChild(param);
 		// we will send all the requests in a single message
-		Element metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
 		for (int i = 0; i < colls.getLength(); i++)
 		{
@@ -209,5 +211,5 @@
 			String name = c.getAttribute(GSXML.NAME_ATT);
 
-			Element metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, name, userContext);
+			Element metadata_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, name, userContext);
 			metadata_request.appendChild(coll_param_list.cloneNode(true));
 			metadata_message.appendChild(metadata_request);
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java	(revision 28382)
@@ -10,4 +10,5 @@
 import org.greenstone.gsdl3.util.UserContext;
 import org.greenstone.util.GlobalProperties;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -26,4 +27,6 @@
 	{
 		Element message = this.converter.nodeToElement(message_node);
+	    Document doc = message.getOwnerDocument();
+	    
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
 		Element paramList = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
@@ -44,5 +47,5 @@
 			page_name = HOME_PAGE;
 		}
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
 		Element response;
 		if (page_name.equals(HOME_PAGE))
@@ -66,6 +69,6 @@
 		}
 
-		Element formatMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element formatRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_FORMAT, collection, new UserContext(request));
+		Element formatMessage = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element formatRequest = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_FORMAT, collection, new UserContext(request));
 		formatMessage.appendChild(formatRequest);
 		Element formatResponseMessage = (Element) this.mr.process(formatMessage);
@@ -78,5 +81,5 @@
 		}
 
-		result.appendChild(this.doc.importNode(response, true));
+		result.appendChild(doc.importNode(response, true));
 		logger.debug("page action result: " + this.converter.getPrettyString(result));
 
@@ -86,8 +89,10 @@
 	protected Element homePage(Element request)
 	{
+		Document doc = request.getOwnerDocument();
+		
 		UserContext userContext = new UserContext(request);
 		// first, get the message router info
-		Element info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element coll_list_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
+		Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element coll_list_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, "", userContext);
 		info_message.appendChild(coll_list_request);
 		Element info_response_message = (Element) this.mr.process(info_message);
@@ -113,5 +118,5 @@
 			if (colls.getLength() > 0)
 			{
-				sendMultipleRequests(colls, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
+				sendMultipleRequests(doc, colls, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
 			}
 		}
@@ -124,5 +129,5 @@
 			if (services.getLength() > 0)
 			{
-				sendMultipleRequests(services, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
+				sendMultipleRequests(doc, services, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
 			}
 		}
@@ -135,5 +140,5 @@
 			if (clusters.getLength() > 0)
 			{
-				sendMultipleRequests(clusters, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
+				sendMultipleRequests(doc, clusters, null, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
 
 			}
@@ -149,4 +154,6 @@
 	protected Element aboutPage(Element request)
 	{
+		Document doc = request.getOwnerDocument();
+		
 		UserContext userContext = new UserContext(request);
 		// extract the params from the cgi-request, 
@@ -159,5 +166,5 @@
 			logger.error("about page requested with no collection or cluster specified!");
 			// return an empty response
-			Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+			Element response = doc.createElement(GSXML.RESPONSE_ELEM);
 			addSiteMetadata(response, userContext);
 			addInterfaceOptions(response);
@@ -166,7 +173,7 @@
 
 		// get the collection or cluster description
-		Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-
-		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
+		Element coll_about_message = doc.createElement(GSXML.MESSAGE_ELEM);
+
+		Element coll_about_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
 		coll_about_message.appendChild(coll_about_request);
 		Element coll_about_response = (Element) this.mr.process(coll_about_message);
@@ -213,5 +220,5 @@
 		if (services.getLength() > 0)
 		{
-			sendMultipleRequests(services, coll_name, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
+			sendMultipleRequests(doc, services, coll_name, GSXML.REQUEST_TYPE_DESCRIBE, userContext);
 		}
 
@@ -231,4 +238,6 @@
 	protected Element unknownPage(Element request)
 	{
+		Document doc = request.getOwnerDocument();
+		
 		UserContext userContext = new UserContext(request);
 		String page_name = request.getAttribute(GSXML.SUBACTION_ATT);
@@ -242,5 +251,5 @@
 		{
 			// just return an empty response
-			Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+			Element response = doc.createElement(GSXML.RESPONSE_ELEM);
 			addSiteMetadata(response, userContext);
 			addInterfaceOptions(response);
@@ -252,7 +261,7 @@
 		// if there is a service specified should we get the service description instead??
 		// get the collection or cluster description
-		Element coll_about_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-
-		Element coll_about_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
+		Element coll_about_message = doc.createElement(GSXML.MESSAGE_ELEM);
+
+		Element coll_about_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, coll_name, userContext);
 		coll_about_message.appendChild(coll_about_request);
 
@@ -269,8 +278,8 @@
 	}
 
-	protected boolean sendMultipleRequests(NodeList items, String path_prefix, String request_type, UserContext userContext)
+	protected boolean sendMultipleRequests(Document doc, NodeList items, String path_prefix, String request_type, UserContext userContext)
 	{
 		// we will send all the requests in a single message
-		Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element message = doc.createElement(GSXML.MESSAGE_ELEM);
 		for (int i = 0; i < items.getLength(); i++)
 		{
@@ -281,5 +290,5 @@
 				path = GSPath.appendLink(path_prefix, path);
 			}
-			Element request = GSXML.createBasicRequest(this.doc, request_type, path, userContext);
+			Element request = GSXML.createBasicRequest(doc, request_type, path, userContext);
 			message.appendChild(request);
 		}
@@ -317,10 +326,12 @@
 	protected Element gli4gs3Page(Element request)
 	{
+		Document doc = request.getOwnerDocument();
+		
 		String lang = request.getAttribute(GSXML.LANG_ATT);
 		String uid = request.getAttribute(GSXML.USER_ID_ATT);
 
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
-
-		Element applet_elem = this.doc.createElement("Applet");
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
+
+		Element applet_elem = doc.createElement("Applet");
 		page_response.appendChild(applet_elem);
 		applet_elem.setAttribute("ARCHIVE", "SignedGatherer.jar");
@@ -329,5 +340,5 @@
 		applet_elem.setAttribute("HEIGHT", "50");
 		applet_elem.setAttribute("WIDTH", "380");
-		Element gwcgi_param_elem = this.doc.createElement("PARAM");
+		Element gwcgi_param_elem = doc.createElement("PARAM");
 		gwcgi_param_elem.setAttribute("name", "gwcgi");
 		String library_name = GlobalProperties.getGSDL3WebAddress();
@@ -335,5 +346,5 @@
 		applet_elem.appendChild(gwcgi_param_elem);
 
-		Element gsdl3_param_elem = this.doc.createElement("PARAM");
+		Element gsdl3_param_elem = doc.createElement("PARAM");
 		gsdl3_param_elem.setAttribute("name", "gsdl3");
 		gsdl3_param_elem.setAttribute("value", "true");
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/ProcessAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/ProcessAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/ProcessAction.java	(revision 28382)
@@ -21,10 +21,10 @@
 	public Node process(Node message_node)
 	{
-
 		Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
 		// the result
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 		result.appendChild(page_response);
 
@@ -70,5 +70,5 @@
 			// if rt=s or rt=r, do the request
 
-			Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+			Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
 			String request_type_att;
 			Element param_list = null;
@@ -76,6 +76,6 @@
 			{ // status
 				request_type_att = GSXML.REQUEST_TYPE_STATUS;
-				param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-				Element param = this.doc.createElement(GSXML.PARAM_ELEM);
+				param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+				Element param = doc.createElement(GSXML.PARAM_ELEM);
 				param.setAttribute(GSXML.NAME_ATT, GSParams.PROCESS_ID);
 				param.setAttribute(GSXML.VALUE_ATT, (String) params.get(GSParams.PROCESS_ID));
@@ -89,10 +89,10 @@
 				if (service_params != null)
 				{
-					param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-					GSXML.addParametersToList(this.doc, param_list, service_params);
+					param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+					GSXML.addParametersToList(doc, param_list, service_params);
 				}
 
 			}
-			Element mr_query_request = GSXML.createBasicRequest(this.doc, request_type_att, to, userContext);
+			Element mr_query_request = GSXML.createBasicRequest(doc, request_type_att, to, userContext);
 			if (param_list != null)
 			{
@@ -112,5 +112,5 @@
 			// else append the contents of the response to the page - just the status elem for now
 			Element status = (Element) GSXML.getChildByTagName(result_response, GSXML.STATUS_ELEM);
-			page_response.appendChild(this.doc.importNode(status, true));
+			page_response.appendChild(doc.importNode(status, true));
 		}
 
@@ -118,6 +118,6 @@
 
 		// request the service info for the selected service - should be cached
-		Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
+		Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 		mr_info_message.appendChild(mr_info_request);
 		Element mr_info_response = (Element) this.mr.process(mr_info_message);
@@ -125,5 +125,5 @@
 		String path = GSXML.RESPONSE_ELEM;
 		path = GSPath.appendLink(path, GSXML.SERVICE_ELEM);
-		Element description = (Element) this.doc.importNode(GSXML.getNodeByPath(mr_info_response, path), true);
+		Element description = (Element) doc.importNode(GSXML.getNodeByPath(mr_info_response, path), true);
 
 		page_response.appendChild(description);
@@ -134,6 +134,7 @@
 	protected Element getServiceParamList(Element cgi_param_list)
 	{
-
-		Element new_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Document doc = cgi_param_list.getOwnerDocument();
+		
+		Element new_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		Element param;
 		NodeList cgi_params = cgi_param_list.getChildNodes();
@@ -147,5 +148,5 @@
 			}
 			// else add it in to the list
-			new_param_list.appendChild(this.doc.importNode(p, true));
+			new_param_list.appendChild(doc.importNode(p, true));
 		}
 		return new_param_list;
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/QueryAction.java	(revision 28382)
@@ -11,4 +11,5 @@
 import org.greenstone.gsdl3.util.GSXSLT;
 import org.greenstone.gsdl3.util.UserContext;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -26,14 +27,14 @@
 	public Node process(Node message_node)
 	{
-
 		Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
 		// get the request - assume there is only one
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
 
 		// create the return message
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
 		Element response = basicQuery(request);
-		result.appendChild(this.doc.importNode(response, true));
+		result.appendChild(doc.importNode(response, true));
 		return result;
 	}
@@ -47,5 +48,6 @@
 	{
 		// the result
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Document doc = request.getOwnerDocument();
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 
 		// extract the params from the cgi-request, and check that we have a coll specified
@@ -75,11 +77,11 @@
 		format_elem.setAttribute(GSXML.TYPE_ATT, "search");
 		// for now just add to the response
-		page_response.appendChild(this.doc.importNode(format_elem, true));
+		page_response.appendChild(doc.importNode(format_elem, true));
 
 		if (request_type.indexOf("d") != -1)
 		{
 			// we have been asked for the service description
-			Element mr_info_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-			Element mr_info_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
+			Element mr_info_message = doc.createElement(GSXML.MESSAGE_ELEM);
+			Element mr_info_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_DESCRIBE, to, userContext);
 			mr_info_message.appendChild(mr_info_request);
 
@@ -90,5 +92,5 @@
 			Element service_response = (Element) GSXML.getChildByTagName(mr_info_response, GSXML.RESPONSE_ELEM);
 
-			Element service_description = (Element) this.doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
+			Element service_description = (Element) doc.importNode(GSXML.getChildByTagName(service_response, GSXML.SERVICE_ELEM), true);
 			page_response.appendChild(service_description);
 		}
@@ -114,10 +116,10 @@
 
 		// create the query request
-		Element mr_query_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_query_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element mr_query_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_query_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_query_message.appendChild(mr_query_request);
 
-		Element query_param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
-		GSXML.addParametersToList(this.doc, query_param_list, service_params);
+		Element query_param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		GSXML.addParametersToList(doc, query_param_list, service_params);
 		mr_query_request.appendChild(query_param_list);
 
@@ -144,5 +146,5 @@
 		else
 		{ // add it into the page response
-			page_response.appendChild(this.doc.importNode(query_result_metadata_list, true));
+			page_response.appendChild(doc.importNode(query_result_metadata_list, true));
 		}
 
@@ -154,5 +156,5 @@
 		else
 		{ // add it into the page response
-			page_response.appendChild(this.doc.importNode(query_term_info_list, true));
+			page_response.appendChild(doc.importNode(query_term_info_list, true));
 		}
 
@@ -164,5 +166,5 @@
 		else
 		{ // add it into the page response
-			page_response.appendChild(this.doc.importNode(facet_list, true));
+			page_response.appendChild(doc.importNode(facet_list, true));
 		}
 
@@ -173,5 +175,5 @@
 		{
 			// add in a dummy doc node list - used by the display. need to think about this
-			page_response.appendChild(this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER));
+			page_response.appendChild(doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER));
 			//append site metadata
 			addSiteMetadata(page_response, userContext);
@@ -186,5 +188,5 @@
 			logger.error("have already found metadata!");
 			// append the doc list to the result
-			page_response.appendChild(this.doc.importNode(document_list, true));
+			page_response.appendChild(doc.importNode(document_list, true));
 			//append site metadata
 			addSiteMetadata(page_response, userContext);
@@ -203,8 +205,8 @@
 
 		// paging of the results is done here - we filter the list to remove unwanted entries before retrieving metadata
-		Element filtered_doc_list = filterDocList(params, service_params, document_list);
+		Element filtered_doc_list = filterDocList(doc, params, service_params, document_list);
 
 		// do the metadata request on the filtered list
-		Element mr_metadata_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_metadata_message = doc.createElement(GSXML.MESSAGE_ELEM);
 		to = "DocumentMetadataRetrieve";
 		if (collection != null)
@@ -212,5 +214,5 @@
 			to = GSPath.prependLink(to, collection);
 		}
-		Element mr_metadata_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element mr_metadata_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_metadata_message.appendChild(mr_metadata_request);
 
@@ -228,5 +230,5 @@
 		}
 
-		Element dm_param_list = createMetadataParamList(metadata_names);
+		Element dm_param_list = createMetadataParamList(doc,metadata_names);
 
 		mr_metadata_request.appendChild(dm_param_list);
@@ -246,5 +248,5 @@
 		if (query_result_document_list != null)
 		{
-			page_response.appendChild(this.doc.importNode(query_result_document_list, true));
+			page_response.appendChild(doc.importNode(query_result_document_list, true));
 		}
 
@@ -257,5 +259,5 @@
 
 	/** this filters out some of the doc results for result paging */
-	protected Element filterDocList(HashMap<String, Serializable> params, HashMap service_params, Element orig_doc_list)
+	protected Element filterDocList(Document doc, HashMap<String, Serializable> params, HashMap service_params, Element orig_doc_list)
 	{
 
@@ -265,5 +267,5 @@
 		{
 			// the service is doing the paging, so we want to display all of the returned docs(???)
-			//    return (Element)this.doc.importNode(orig_doc_list, true);
+			//    return (Element)doc.importNode(orig_doc_list, true);
 			// try hitsPerPage in the globle param
 			hits_pp = (String) params.get("hitsPerPage");
@@ -285,5 +287,5 @@
 		if (hits == -1)
 		{ // all
-			return (Element) this.doc.importNode(orig_doc_list, true);
+			return (Element) doc.importNode(orig_doc_list, true);
 		}
 		NodeList result_docs = orig_doc_list.getElementsByTagName(GSXML.DOC_NODE_ELEM);
@@ -293,9 +295,9 @@
 		{
 			// too few docs to do paging
-			return (Element) this.doc.importNode(orig_doc_list, true);
+			return (Element) doc.importNode(orig_doc_list, true);
 		}
 
 		// now we need our own doc list
-		Element result_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element result_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 
 		String start_p = (String) service_params.get("startPage");
@@ -335,5 +337,5 @@
 		for (int i = start_from; i <= end_at; i++)
 		{
-			result_list.appendChild(this.doc.importNode(result_docs.item(i), true));
+			result_list.appendChild(doc.importNode(result_docs.item(i), true));
 		}
 
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/RSSAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/RSSAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/RSSAction.java	(revision 28382)
@@ -4,4 +4,5 @@
 
 // XML classes
+import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.Element;
@@ -26,7 +27,7 @@
 	public Node process(Node message_node)
 	{
-
 		Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
 		// assume only one request
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
@@ -45,6 +46,6 @@
 		// this should be cached somehow later on. 
     
-		Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element rss_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element rss_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_request_message.appendChild(rss_request);
 
@@ -58,6 +59,6 @@
 		addInterfaceOptions(rss_response);
 
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		result.appendChild(this.doc.importNode(rss_response, true));
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
+		result.appendChild(doc.importNode(rss_response, true));
 		return result;
 
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java	(revision 28382)
@@ -4,4 +4,5 @@
 
 // XML classes
+import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.Element;
@@ -28,7 +29,7 @@
 	public Node process(Node message_node)
 	{
-
 		Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
 		// assume only one request
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
@@ -40,5 +41,5 @@
 		HashMap<String, Serializable> params = GSXML.extractParams(cgi_param_list, false);
 
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
 
 		String coll = (String) params.get(GSParams.SYSTEM_CLUSTER);
@@ -50,9 +51,9 @@
 		}
 
-		Element mr_request_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element mr_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_SYSTEM, to, userContext);
+		Element mr_request_message = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_SYSTEM, to, userContext);
 		mr_request_message.appendChild(mr_request);
 
-		Element system = this.doc.createElement(GSXML.SYSTEM_ELEM);
+		Element system = doc.createElement(GSXML.SYSTEM_ELEM);
 		mr_request.appendChild(system);
 
@@ -109,5 +110,5 @@
 				// for now just have an error
 				logger.error("bad subaction type");
-				Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+				Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 				result.appendChild(page_response);
 
@@ -118,5 +119,5 @@
 		Node response_message = this.mr.process(mr_request_message);
 
-		Element response = GSXML.duplicateWithNewName(this.doc, (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true);
+		Element response = GSXML.duplicateWithNewName(doc, (Element) GSXML.getChildByTagName(response_message, GSXML.RESPONSE_ELEM), GSXML.RESPONSE_ELEM, true);
 		addSiteMetadata(response, userContext);
 		addInterfaceOptions(response);
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/XMLDocumentAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/XMLDocumentAction.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/XMLDocumentAction.java	(revision 28382)
@@ -28,13 +28,13 @@
 	public Node process(Node message_node)
 	{
-
 		Element message = this.converter.nodeToElement(message_node);
-
+	    Document doc = message.getOwnerDocument();
+	    
 		// get the request - assume there is only one
 		Element request = (Element) GSXML.getChildByTagName(message, GSXML.REQUEST_ELEM);
 
 		// create the return message
-		Element result = this.doc.createElement(GSXML.MESSAGE_ELEM);
-		Element page_response = this.doc.createElement(GSXML.RESPONSE_ELEM);
+		Element result = doc.createElement(GSXML.MESSAGE_ELEM);
+		Element page_response = doc.createElement(GSXML.RESPONSE_ELEM);
 		result.appendChild(page_response);
 
@@ -75,24 +75,24 @@
 
 		// make the request to the collection
-		Element mr_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
+		Element mr_message = doc.createElement(GSXML.MESSAGE_ELEM);
 
-		Element ret_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element ret_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		mr_message.appendChild(ret_request);
 
-		Element doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
+		Element doc_list = doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
 		ret_request.appendChild(doc_list);
-		Element doc = this.doc.createElement(GSXML.DOC_NODE_ELEM);
-		doc.setAttribute(GSXML.NODE_ID_ATT, doc_name);
-		doc_list.appendChild(doc);
+		Element docelem = doc.createElement(GSXML.DOC_NODE_ELEM);
+		docelem.setAttribute(GSXML.NODE_ID_ATT, doc_name);
+		doc_list.appendChild(docelem);
 
 		// also add in a request for the Title metadata
 		to = GSPath.appendLink(collection, "DocumentMetadataRetrieve");
-		Element meta_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
+		Element meta_request = GSXML.createBasicRequest(doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
 		// copy the doc list
 		meta_request.appendChild(doc_list.cloneNode(true));
 		// add in a metadata param
-		Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
+		Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
 		meta_request.appendChild(param_list);
-		Element param = GSXML.createParameter(this.doc, "metadata", "root_Title");
+		Element param = GSXML.createParameter(doc, "metadata", "root_Title");
 		param_list.appendChild(param);
 
@@ -103,5 +103,5 @@
 		String[] links = { GSXML.RESPONSE_ELEM, GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER, GSXML.DOC_NODE_ELEM };
 		String path = GSPath.createPath(links);
-		Element doc_node = (Element) this.doc.importNode(GSXML.getNodeByPath(ret_response, path), true);
+		Element doc_node = (Element) doc.importNode(GSXML.getNodeByPath(ret_response, path), true);
 		page_response.appendChild(doc_node);
 
@@ -114,5 +114,5 @@
 		if (meta_list != null)
 		{
-			doc_node.appendChild(this.doc.importNode(meta_list, true));
+			doc_node.appendChild(doc.importNode(meta_list, true));
 		}
 		return result;
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLConverter.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLConverter.java	(revision 28295)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLConverter.java	(revision 28382)
@@ -266,5 +266,5 @@
 
 	/** creates a new empty DOM Document */
-	public static Document newDOM()
+	public Document newDOM()
 	{
 		Document doc = new DocumentImpl();
