Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 25422)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 25423)
@@ -618,5 +618,5 @@
 
 			Transformer preProcessor = transformerFactory.newTransformer(new DOMSource(preprocessingXsl));
-			preProcessor.setErrorListener(new XMLTransformer.TransformErrorListener());
+			preProcessor.setErrorListener(new XMLTransformer.TransformErrorListener(preprocessingXsl));
 			DOMResult result = new DOMResult();
 			result.setNode(skinAndLibraryDoc);
@@ -864,5 +864,5 @@
 			transformer.transform(domSource, result);
 			content = writer.toString();
-			System.out.println("Change the & to &Amp; for proper debug dispay");
+			System.out.println("Change the & to &Amp; for proper debug display");
 			content = StringUtils.replace(content, "&", "&amp;");
 			writer.flush();
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java	(revision 25422)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java	(revision 25423)
@@ -31,4 +31,5 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.OutputKeys;
 
 import java.util.Map;
@@ -1234,18 +1235,33 @@
 	}
 
-	public static void elementToLogAsString(Element e)
-	{
-		try
-		{
-			TransformerFactory tf = TransformerFactory.newInstance();
-			Transformer trans = tf.newTransformer();
-			StringWriter sw = new StringWriter();
-			trans.transform(new DOMSource(e), new StreamResult(sw));
-			System.err.println(sw.toString());
-		}
-		catch (Exception ex)
-		{
-			System.err.println("couldn't write " + e + " to log");
-		}
+    public static void elementToLogAsString(Element e, boolean indent)
+    {
+	String str = elementToString(e, indent);
+	System.err.println(str);
+	logger.error(str);
+    }
+
+    public static String elementToString(Element e, boolean indent)
+	{
+	    String str = "**********START*************\n";
+	    try {
+		TransformerFactory tf = TransformerFactory.newInstance();
+		Transformer trans = tf.newTransformer();
+		StringWriter sw = new StringWriter();
+		if(indent) {
+		    trans.setOutputProperty(OutputKeys.INDENT, "yes");
+		} else {
+		    trans.setOutputProperty(OutputKeys.INDENT, "no");
+		}
+		trans.transform(new DOMSource(e), new StreamResult(sw));
+		str += sw.toString();
+	    }
+	    catch (Exception ex) {
+		str += "Exception: couldn't write " + e + " to log";
+	    } 
+	    finally {
+		str += "\n***********************\n";
+		return str;
+	    }
 	}
 
Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLTransformer.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLTransformer.java	(revision 25422)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLTransformer.java	(revision 25423)
@@ -42,4 +42,6 @@
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.io.BufferedReader;
+import java.io.FileReader;
 import java.io.File;
 import java.util.HashMap;
@@ -116,5 +118,5 @@
 	    // Use the TransformerFactory to process the stylesheet Source and generate a Transformer.
 	    Transformer transformer = this.t_factory.newTransformer(new StreamSource(stylesheet));
-		transformer.setErrorListener(new TransformErrorListener());
+		transformer.setErrorListener(new TransformErrorListener(stylesheet));
 
 	    // Use the Transformer to transform an XML Source and send the output to a Result object.
@@ -142,5 +144,5 @@
 	    // Use the TransformerFactory to process the stylesheet Source and generate a Transformer.
 	    Transformer transformer = this.t_factory.newTransformer(new DOMSource(stylesheet));
-		transformer.setErrorListener(new TransformErrorListener());
+		transformer.setErrorListener(new TransformErrorListener(stylesheet));
 	    if (parameters != null) {
 		Set params = parameters.entrySet();
@@ -182,5 +184,5 @@
 			Transformer transformer = this.t_factory.newTransformer(new DOMSource(stylesheet));
             logger.info("XMLTransformer transformer is " + transformer);
-			transformer.setErrorListener(new TransformErrorListener());
+			transformer.setErrorListener(new TransformErrorListener(stylesheet));
 			if (parameters != null) {
 				Set params = parameters.entrySet();
@@ -214,5 +216,5 @@
 	try {
 	    Transformer transformer = this.t_factory.newTransformer(new StreamSource(stylesheet));
-		transformer.setErrorListener(new TransformErrorListener());
+		transformer.setErrorListener(new TransformErrorListener(stylesheet));
 	    DOMResult result = new DOMResult();
 	    transformer.transform(new StreamSource(source), result);
@@ -233,5 +235,5 @@
     	try {
     	    Transformer transformer = this.t_factory.newTransformer(new StreamSource(stylesheet));
-			transformer.setErrorListener(new TransformErrorListener());
+			transformer.setErrorListener(new TransformErrorListener(stylesheet));
     	    DOMResult result = new DOMResult(docDocType);
     	    transformer.transform(new StreamSource(source), result);
@@ -320,43 +322,86 @@
 	// be retrieved and be used to generate an xhtml error page.
 	static public class TransformErrorListener implements ErrorListener {
-		protected String errorMessage = null;
-	
-		//  Receive notification of a recoverable error.
-		public void error(TransformerException exception) {
-			handleError("Error:\n", exception);
-		}
-        //   Receive notification of a non-recoverable error.
-		public void fatalError(TransformerException exception) {
-			handleError("Fatal Error:\n", exception);
-		}
-		// Receive notification of a warning.
-        public void warning(TransformerException exception) {
-			handleError("Warning:\n", exception);
-        }
+	    protected String errorMessage = null;
+	    protected String stylesheet = null;
+	    protected String file = null;
+	    
+	    public TransformErrorListener(String xslt) { 
+		this.stylesheet = xslt; 
+	    }
+
+	    public TransformErrorListener(Document xslt) { 
+		//this.stylesheet = GSXML.xmlNodeToString(xslt); 
+		this.stylesheet = GSXML.elementToString(xslt.getDocumentElement(), true);
+	    }
+
+	    public TransformErrorListener(File xslt) { 
+		stylesheet = "";		
+		file = xslt.getAbsolutePath();
+		String error = "Can't locate stylesheet file: " + xslt;
+
+		if(!xslt.exists()) {
+		    stylesheet = error;
+		    System.err.println("@@@@@@@ " + error);
+		    return;
+		}
+		try {
+		    BufferedReader in = new BufferedReader(new FileReader(xslt));
+		    String line = "";
+		    while((line = in.readLine()) != null) {
+			stylesheet = stylesheet + line + "\n";
+		    }
+		    in.close();
+		    in = null;
+		} catch(Exception e) {
+		    stylesheet = error;
+		    System.err.println("Exception reading file: " + xslt.getAbsolutePath());
+		    e.printStackTrace();
+		}
+	    }
+
+	    //  Receive notification of a recoverable error.
+	    public void error(TransformerException exception) {
+		handleError("Error:\n", exception);
+	    }
+	    // Receive notification of a non-recoverable error.
+	    public void fatalError(TransformerException exception) {
+		handleError("Fatal Error:\n", exception);
+	    }
+	    // Receive notification of a warning.
+	    public void warning(TransformerException exception) {
+		handleError("Warning:\n", exception);
+	    }
 		
-		public String toString(TransformerException e) {
-			String location = e.getLocationAsString();
-			if(location == null) {
-				return e.getMessage();
-			}
-			return e.getMessage() + "\n" + location;
-		}
-		
-		// clears the errorPage variable after first call to this method
-		public String getErrorMessage() {
-			String errMsg = this.errorMessage;
-			if(this.errorMessage != null) {
-				this.errorMessage = null;
-			}
-			return errMsg;
-		}
-		
-		// sets the errorMessage member variable to the data stored in the exception
-		// and writes the errorMessage to the logger and tomcat's System.err
-		protected void handleError(String errorType, TransformerException exception) {
-			this.errorMessage = errorType + toString(exception); 
-			System.err.println("\n****Error transforming xml:\n" + this.errorMessage + "\n****\n");
-			logger.error(this.errorMessage);
-		}
+	    public String toString(TransformerException e) {
+		String msg = "Exception encountered was:\n\t";
+		String location = e.getLocationAsString();
+		if(location != null) {		    
+		    msg = msg + "Location: " + location + "\n\t";
+		} 
+
+		return msg + "Message: " + e.getMessage();
+	    }
+	    
+	    // clears the errorPage variable after first call to this method
+	    public String getErrorMessage() {
+		String errMsg = this.errorMessage;
+		if(this.errorMessage != null) {
+		    this.errorMessage = null;
+		}
+		return errMsg;
+	    }
+	    
+	    // sets the errorMessage member variable to the data stored in the exception
+	    // and writes the errorMessage to the logger and tomcat's System.err
+	    protected void handleError(String errorType, TransformerException exception) {
+		this.errorMessage = errorType + toString(exception); 
+		if(file != null) { 
+		    this.errorMessage = this.errorMessage + "\nfilename: " + file;
+		}
+		this.errorMessage += "\nException CAUSE:\n" + exception.getCause();
+		System.err.println("\n****Error transforming xml:\n" + this.errorMessage + "\n****\n");
+		System.err.println("Stylesheet was:\n" + this.stylesheet + "\n\n");
+		logger.error(this.errorMessage);
+	    }
 	}
 }
