Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 25895)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 25912)
@@ -92,5 +92,4 @@
 			e.printStackTrace();
 		}
-
 	}
 
@@ -559,5 +558,4 @@
 		//for debug purposes only
 		Document oldStyle_doc = style_doc;
-
 		Document preprocessingXsl;
 		try
@@ -641,61 +639,9 @@
 		}
 
-		//The following code is to be uncommented if we need to append the extracted GSF statements
-		//after having extracted the GSLib elements. In case of a problem during postprocessing.
-		/*
-		 * // put the page into a document - this is necessary for xslt to get
-		 * // the paths right if you have paths relative to the document root //
-		 * eg /page. Document doc = this.converter.newDOM();
-		 * doc.appendChild(doc.importNode(page, true)); Element page_response =
-		 * (Element)GSXML.getChildByTagName(page, GSXML.PAGE_RESPONSE_ELEM);
-		 * Element format_elem = (Element)GSXML.getChildByTagName(page_response,
-		 * GSXML.FORMAT_ELEM); if (output.equals("formatelem")) { return
-		 * format_elem; } if (format_elem != null) {
-		 * //page_response.removeChild(format_elem);
-		 * logger.debug("format elem="+
-		 * this.converter.getPrettyString(format_elem)); // need to transform
-		 * the format info String configStylesheet_file =
-		 * GSFile.stylesheetFile(GlobalProperties.getGSDL3Home(),
-		 * (String)this.config_params.get(GSConstants.SITE_NAME), collection,
-		 * (String)this.config_params.get(GSConstants.INTERFACE_NAME),
-		 * base_interfaces, "config_format.xsl"); Document configStylesheet_doc
-		 * = this.converter.getDOM(new File(configStylesheet_file)); if
-		 * (configStylesheet_doc != null) { Document format_doc =
-		 * this.converter.newDOM();
-		 * format_doc.appendChild(format_doc.importNode(format_elem, true));
-		 * Node result = this.transformer.transform(configStylesheet_doc,
-		 * format_doc);
-		 * 
-		 * // Since we started creating documents with DocTypes, we can end up
-		 * with // Document objects here. But we will be working with an Element
-		 * instead, // so we grab the DocumentElement() of the Document object
-		 * in such a case. Element new_format; if(result.getNodeType() ==
-		 * Node.DOCUMENT_NODE) { new_format =
-		 * ((Document)result).getDocumentElement(); } else { new_format =
-		 * (Element)result; }
-		 * logger.debug("new format elem="+this.converter.getPrettyString
-		 * (new_format)); if (output.equals("newformat")) { return new_format; }
-		 * 
-		 * // add extracted GSF statements in to the main stylesheet
-		 * GSXSLT.mergeStylesheets(skinAndLibraryDoc, new_format);
-		 * //System.out.println
-		 * ("added extracted GSF statements into the main stylesheet") ;
-		 * 
-		 * // add extracted GSF statements in to the debug test stylesheet
-		 * //GSXSLT.mergeStylesheets(oldStyle_doc, new_format); } else {
-		 * logger.error(
-		 * " couldn't parse the config_format stylesheet, adding the format info as is"
-		 * ); GSXSLT.mergeStylesheets(skinAndLibraryDoc, format_elem); //
-		 * GSXSLT.mergeStylesheets(oldStyle_doc, format_elem); }
-		 * logger.debug("the converted stylesheet is:");
-		 * logger.debug(this.converter
-		 * .getPrettyString(skinAndLibraryDoc.getDocumentElement())); }
-		 */
-
 		// there is a thing called a URIResolver which you can set for a
 		// transformer or transformer factory. may be able to use this
 		// instead of this absoluteIncludepaths hack
 
-		GSXSLT.absoluteIncludePaths(skinAndLibraryDoc, GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces);
+		//GSXSLT.absoluteIncludePaths(skinAndLibraryDoc, GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces);
 
 		//Same but for the debug version when we want the do the transformation like we use to do
@@ -793,7 +739,10 @@
 		}
 
-		if (skinAndLibraryDoc.getElementsByTagName("gsf:metadata").getLength() > 0)
-		{
-			secondConfigFormatPass(collection, skinAndLibraryDoc, doc, new UserContext(request));
+		GSXSLT.inlineImportAndIncludeFiles(skinAndLibraryDoc, null);
+		skinAndLibraryDoc = (Document) secondConfigFormatPass(collection, skinAndLibraryDoc, doc, new UserContext(request));
+
+		if (_debug)
+		{
+			GSXML.addDebugSpanTags(skinAndLibraryDoc);
 		}
 
@@ -803,12 +752,9 @@
 		}
 
-		if (_debug)
-		{
-			GSXML.addDebugSpanTags(skinAndLibraryDoc);
-		}
 		if (output.equals("skinandlibdocfinal"))
 		{
 			return converter.getDOM(getStringFromDocument(skinAndLibraryDoc));
 		}
+
 		return this.transformer.transform(skinAndLibraryDoc, doc, config_params, docWithDoctype);
 
@@ -820,5 +766,5 @@
 	}
 
-	protected void secondConfigFormatPass(String collection, Document skinAndLibraryDoc, Document doc, UserContext userContext)
+	protected Node secondConfigFormatPass(String collection, Document skinAndLibraryDoc, Document doc, UserContext userContext)
 	{
 		String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve"); // Hard-wired?
@@ -863,20 +809,7 @@
 		if (configStylesheet_doc != null)
 		{
-			Document format_doc = XMLConverter.newDOM();
-			format_doc.appendChild(format_doc.importNode(skinAndLibraryDoc.getDocumentElement().cloneNode(true), true));
-			Node result = this.transformer.transform(configStylesheet_doc, format_doc, config_params);
-			if (_debug)
-			{
-				GSXSLT.mergeStylesheetsDebug(skinAndLibraryDoc, ((Document) result).getDocumentElement(), true, true, "OTHER3", GSFile.collectionConfigFile(GSFile.collectDir(GSFile.siteHome(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME)) + File.separator + collection)));
-			}
-			else
-			{
-				GSXSLT.mergeStylesheets(skinAndLibraryDoc, ((Document) result).getDocumentElement(), true);
-				// we just want the result of the transform to be in skinAndLibraryDoc
-				Element old_doc = skinAndLibraryDoc.getDocumentElement();
-				skinAndLibraryDoc.removeChild(old_doc);
-				skinAndLibraryDoc.appendChild(skinAndLibraryDoc.importNode(((Document) result).getDocumentElement(), true));
-			}
-		}
+			return this.transformer.transform(configStylesheet_doc, skinAndLibraryDoc, config_params);
+		}
+		return skinAndLibraryDoc;
 	}
 
@@ -933,5 +866,4 @@
 		// now find the absolute path
 		ArrayList<File> stylesheets = GSFile.getStylesheetFiles(GlobalProperties.getGSDL3Home(), (String) this.config_params.get(GSConstants.SITE_NAME), collection, (String) this.config_params.get(GSConstants.INTERFACE_NAME), base_interfaces, name);
-
 		if (stylesheets.size() == 0)
 		{
@@ -963,9 +895,4 @@
 				GSXSLT.mergeStylesheets(finalDoc, currentDoc.getDocumentElement(), true);
 			}
-		}
-
-		if (_debug)
-		{
-			GSXSLT.inlineImportAndIncludeFiles(finalDoc, null, 0);
 		}
 
