Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java	(revision 23333)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/SystemAction.java	(revision 23336)
@@ -17,4 +17,7 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
 
 import org.apache.log4j.*;
@@ -75,5 +78,6 @@
             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             DocumentBuilder builder = factory.newDocumentBuilder();
-            InputSource is = new InputSource( new StringReader( format_string ) );
+            String input = "<html><head><title></title></head><body>" + format_string + "</body></html>";
+            InputSource is = new InputSource( new StringReader( input ) );
             Document d = builder.parse( is );
             page_response.appendChild(d);
@@ -81,4 +85,11 @@
         catch( Exception ex ) {
             logger.error("There was an exception "+ex);
+            
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw, true);
+            ex.printStackTrace(pw);
+            pw.flush();
+            sw.flush();
+            logger.error(sw.toString());
         }
 
Index: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java
===================================================================
--- main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 23333)
+++ main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/TransformingReceptionist.java	(revision 23336)
@@ -548,5 +548,5 @@
     String publicID = "-//W3C//DTD HTML 4.01 Transitional//EN";
     String systemID = "http://www.w3.org/TR/html4/loose.dtd";
-		
+
     // Try to get the system and public ID from the current skin xsl document
     // otherwise keep the default values.
Index: main/trunk/greenstone3/web/interfaces/default/transform/classifier.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/transform/classifier.xsl	(revision 23333)
+++ main/trunk/greenstone3/web/interfaces/default/transform/classifier.xsl	(revision 23336)
@@ -61,28 +61,4 @@
     </xsl:call-template>      
   
-    <!-- Sam's div code -->
-
-    <!-- <xsl:if test="/page/pageRequest[@name='output']='debug'"> -->
-
-    <xsl:variable name="fmt">
-	<xsl:call-template name="xml-to-string">
-            <xsl:with-param name="node-set" select="//format[@type='browse']"/>
-          </xsl:call-template>
-    </xsl:variable>
-
-    <!-- <xsl:variable name="tok" select="fn:tokenize($fmt,'/s+')"/> -->
-
-      <div id="format">
-        <p>
-	  <b>Format string here</b>
-	  <i>
-	      <xsl:value-of select="$fmt"/>
-	      <!-- <xsl:value-of select="$tok"/> -->
-	  </i>
-        </p>
-      </div>
-    <!-- </xsl:if> -->
-
-  
     <div id="content">
       <xsl:apply-templates select="service/classifierList">
Index: main/trunk/greenstone3/web/interfaces/default/transform/util.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/transform/util.xsl	(revision 23333)
+++ main/trunk/greenstone3/web/interfaces/default/transform/util.xsl	(revision 23336)
@@ -11,6 +11,4 @@
   <xsl:param name="library_name"/>
 
-  <xsl:include href="xml-to-string.xsl"/>
-  
   <!-- every pages ................................................. -->
   
Index: main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 23333)
+++ main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 23336)
@@ -7,6 +7,8 @@
 {
 
-    var formatStatement = document.getElementById('formatStatement').innerHTML;
-    //console.log(formatStatement);
+    var formatDiv = document.getElementById('formatStatement');
+    var formatStatement = innerXHTML(formatDiv);
+    console.log(formatStatement);
+
 
     //var myurl = 'http://localhost:8080/greenstone3/format?a=s&sa=s&t='+formatStatement;
@@ -15,5 +17,5 @@
 
     $.post("http://localhost:8080/greenstone3/format?a=s&sa=s", {data: formatStatement}, function(data) {
-        $('.result').innerHTML = data; //html(data);
+        //$('.result').innerHTML = data; //html(data);
         console.log("Success, we have received data");
         console.log(data);
Index: main/trunk/greenstone3/web/interfaces/oran/js/innerxhtml.js
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/js/innerxhtml.js	(revision 23336)
+++ main/trunk/greenstone3/web/interfaces/oran/js/innerxhtml.js	(revision 23336)
@@ -0,0 +1,162 @@
+/*
+Written by Steve Tucker, 2006, http://www.stevetucker.co.uk
+Full documentation can be found at http://www.stevetucker.co.uk/page-innerxhtml.php
+Released under the Creative Commons Attribution-Share Alike 3.0  License, http://creativecommons.org/licenses/by-sa/3.0/
+
+Change Log
+----------
+15/10/2006  v0.3    innerXHTML official release.
+21/03/2007  v0.4    1. Third argument $appendage added (Steve Tucker & Stef Dawson, www.stefdawson.com)
+            2. $source argument accepts string ID (Stef Dawson)
+            3. IE6 'on' functions work (Stef Dawson & Steve Tucker)
+*/
+innerXHTML = function($source,$string,$appendage) {
+    // (v0.4) Written 2006 by Steve Tucker, http://www.stevetucker.co.uk
+    if (typeof($source) == 'string') $source = document.getElementById($source);
+    if (!($source.nodeType == 1)) return false;
+    var $children = $source.childNodes;
+    var $xhtml = '';
+    if (!$string) {
+        for (var $i=0; $i<$children.length; $i++) {
+            if ($children[$i].nodeType == 3) {
+                var $text_content = $children[$i].nodeValue;
+                $text_content = $text_content.replace(/</g,'&lt;');
+                $text_content = $text_content.replace(/>/g,'&gt;');
+                $xhtml += $text_content;
+            }
+            else if ($children[$i].nodeType == 8) {
+                $xhtml += '<!--'+$children[$i].nodeValue+'-->';
+            }
+            else {
+                $xhtml += '<'+$children[$i].nodeName.toLowerCase();
+                var $attributes = $children[$i].attributes;
+                for (var $j=0; $j<$attributes.length; $j++) {
+                    var $attName = $attributes[$j].nodeName.toLowerCase();
+                    var $attValue = $attributes[$j].nodeValue;
+                    if ($attName == 'style' && $children[$i].style.cssText) {
+                        $xhtml += ' style="'+$children[$i].style.cssText.toLowerCase()+'"';
+                    }
+                    else if ($attValue && $attName != 'contenteditable') {
+                        $xhtml += ' '+$attName+'="'+$attValue+'"';
+                    }
+                }
+                $xhtml += '>'+innerXHTML($children[$i]);
+                $xhtml += '</'+$children[$i].nodeName.toLowerCase()+'>';
+            }
+        }
+    }
+    else {
+        if (!$appendage) {
+            while ($children.length>0) {
+                $source.removeChild($children[0]);
+            }
+            $appendage = false;
+        }
+        $xhtml = $string;
+        while ($string) {
+            var $returned = translateXHTML($string);
+            var $elements = $returned[0];
+            $string = $returned[1];
+            if ($elements) {
+                if (typeof($appendage) == 'string') $appendage = document.getElementById($appendage);
+                if (!($appendage.nodeType == 1)) $source.appendChild($elements);
+                else $source.insertBefore($elements,$appendage);
+            }
+        }
+    }
+    return $xhtml;
+}
+function translateXHTML($string) {
+    var $match = /^<\/[a-z0-9]{1,}>/i.test($string);
+    if ($match) {
+        var $return = Array;
+        $return[0] = false;
+        $return[1] = $string.replace(/^<\/[a-z0-9]{1,}>/i,'');
+        return $return;
+    }
+    $match = /^<[a-z]{1,}/i.test($string);
+    if ($match) {
+        $string = $string.replace(/^</,'');
+        var $element = $string.match(/[a-z0-9]{1,}/i);
+        if ($element) {
+            var $new_element = document.createElement($element[0]);
+            $string = $string.replace(/[a-z0-9]{1,}/i,'');
+            var $attribute = true;
+            while ($attribute) {
+                $string = $string.replace(/^\s{1,}/,'');
+                $attribute = $string.match(/^[a-z1-9_-]{1,}="[^"]{0,}"/i);
+                if ($attribute) {
+                    $attribute = $attribute[0];
+                    $string = $string.replace(/^[a-z1-9_-]{1,}="[^"]{0,}"/i,'');
+                    var $attName = $attribute.match(/^[a-z1-9_-]{1,}/i);
+                    $attribute = $attribute.replace(/^[a-z1-9_-]{1,}="/i,'');
+                    $attribute = $attribute.replace(/;{0,1}"$/,'');
+                    if ($attribute) {
+                        var $attValue = $attribute;
+                        if ($attName == 'value') $new_element.value = $attValue;
+                        else if ($attName == 'class') $new_element.className = $attValue;
+                        else if ($attName == 'style') {
+                            var $style = $attValue.split(';');
+                            for (var $i=0; $i<$style.length; $i++) {
+                                var $this_style = $style[$i].split(':');
+                                $this_style[0] = $this_style[0].toLowerCase().replace(/(^\s{0,})|(\s{0,1}$)/,'');
+                                $this_style[1] = $this_style[1].toLowerCase().replace(/(^\s{0,})|(\s{0,1}$)/,'');
+                                if (/-{1,}/g.test($this_style[0])) {
+                                    var $this_style_words = $this_style[0].split(/-/g);
+                                    $this_style[0] = '';
+                                    for (var $j=0; $j<$this_style_words.length; $j++) {
+                                        if ($j==0) {
+                                            $this_style[0] = $this_style_words[0];
+                                            continue;
+                                        }
+                                        var $first_letter = $this_style_words[$j].toUpperCase().match(/^[a-z]{1,1}/i);
+                                        $this_style[0] += $first_letter+$this_style_words[$j].replace(/^[a-z]{1,1}/,'');
+                                    }
+                                }
+                                $new_element.style[$this_style[0]] = $this_style[1];
+                            }
+                        }
+                        else if (/^on/.test($attName)) $new_element[$attName] = function() { eval($attValue) };
+                        else $new_element.setAttribute($attName,$attValue);
+                    }
+                    else $attribute = true;
+                }
+            }
+            $match = /^>/.test($string);
+            if ($match) {
+                $string = $string.replace(/^>/,'');
+                var $child = true;
+                while ($child) {
+                    var $returned = translateXHTML($string,false);
+                    $child = $returned[0];
+                    if ($child) $new_element.appendChild($child);
+                    $string = $returned[1];
+                }
+            }
+            $string = $string.replace(/^\/>/,'');
+        }
+    }
+    $match = /^[^<>]{1,}/i.test($string);
+    if ($match && !$new_element) {
+        var $text_content = $string.match(/^[^<>]{1,}/i)[0];
+        $text_content = $text_content.replace(/&lt;/g,'<');
+        $text_content = $text_content.replace(/&gt;/g,'>');
+        var $new_element = document.createTextNode($text_content);
+        $string = $string.replace(/^[^<>]{1,}/i,'');
+    }
+    $match = /^<!--[^<>]{1,}-->/i.test($string);
+    if ($match && !$new_element) {
+        if (document.createComment) {
+            $string = $string.replace(/^<!--/i,'');
+            var $text_content = $string.match(/^[^<>]{0,}-->{1,}/i);
+            $text_content = $text_content[0].replace(/-->{1,1}$/,'');           
+            var $new_element = document.createComment($text_content);
+            $string = $string.replace(/^[^<>]{1,}-->/i,'');
+        }
+        else $string = $string.replace(/^<!--[^<>]{1,}-->/i,'');
+    }
+    var $return = Array;
+    $return[0] = $new_element;
+    $return[1] = $string;
+    return $return;
+}
Index: main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 23333)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 23336)
@@ -2,4 +2,5 @@
 <xsl:stylesheet version="1.0"
 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+
 	xmlns:java="http://xml.apache.org/xslt/java"
 	xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
@@ -23,5 +24,6 @@
 
 	<!-- the output format for this layout is html -->
-	<xsl:output method="html" omit-xml-declaration="yes"/>  
+    <!-- <xsl:output method="xml" version="1.0" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" indent="yes" omit-xml-declaration="yes"/> -->
+	<xsl:output method="html" omit-xml-declaration="yes"/> 
 
 	<!-- the main layout is defined here -->
@@ -130,4 +132,5 @@
 <!-- Sam2's div code -->
 
+    <script type="text/javascript" src="interfaces/oran/js/innerxhtml.js"><xsl:text> </xsl:text></script>
     <script type="text/javascript" src="interfaces/oran/js/gui_div.js"><xsl:text> </xsl:text></script>
    
@@ -177,10 +180,11 @@
 
     <div id="formatStatement">
-
+        <div id="formatRoot">
+    
     <xsl:call-template name="xml-to-gui">
         <xsl:with-param name="node-set" select="//format"/> <!-- [@type='browse']"/>  -->
         <xsl:with-param name="metadataSets" select="//metadataSetList"/> 
     </xsl:call-template> 
-
+        </div>
     </div>
     </td>    
Index: main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl	(revision 23333)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl	(revision 23336)
@@ -196,21 +196,21 @@
                     <xsl:choose>
                         <xsl:when test="@type='document'">
-        	                <option value = "document" selected = "document">Document</option>
+        	                <option value = "document" selected = "selected">Document</option>
 	                        <option value = "classifier">Classifier</option>
                             <option value = "source">Source</option>
                         </xsl:when>
                         <xsl:when test="@type='classifier'">
-	                        <option value = "classifier" selected = "classifier">Classifier</option>
+	                        <option value = "classifier" selected = "selected">Classifier</option>
                             <option value = "document">Document</option>
                             <option value = "source">Source</option>
                         </xsl:when>
                         <xsl:when test="@type='source'">
-                	        <option value = "source" selected = "source">Source</option>
+                	        <option value = "source" selected = "selected">Source</option>
                             <option value ="document">Document</option>
                             <option value ="classifier">Classifier</option>
                         </xsl:when>
                         <xsl:when test="@type='horizontal'">
-                            <option value = "horizontal" selected = "horizontal">Horizontal</option>
-                            <option value = "source" selected = "source">Source</option>
+                            <option value = "horizontal" selected = "selected">Horizontal</option>
+                            <option value = "source">Source</option>
                             <option value ="document">Document</option>
                             <option value ="classifier">Classifier</option>
@@ -236,10 +236,10 @@
             <xsl:variable name="mode">
                 <xsl:choose>
-                    <xsl:when test="not(@mode)">MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="vertical"></input></xsl:when>
-                    <xsl:otherwise>MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="{@mode}"></input></xsl:otherwise>
+                    <xsl:when test="not(@mode)">MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="vertical"><xsl:text></xsl:text></input></xsl:when>
+                    <xsl:otherwise>MODE=<input class="mode" type="text" name="rawtextinput" size="10" value="{@mode}"/></xsl:otherwise>
                 </xsl:choose>
             </xsl:variable>
     
-            <table class="header"><tbody><tr><td class="header">MATCH=<input class="match" type="text" name="rawtextinput" size="10" value="{@match}"></input></td><td class="header"><xsl:copy-of select="$mode"/></td><td class="header"><a href="#" class="minmax ui-icon ui-icon-plusthick" title="Click me to expand">[+]</a></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
+            <table class="header"><tbody><tr><td class="header">MATCH=<input class="match" type="text" name="rawtextinput" size="10" value="{@match}"/></td><td class="header"><xsl:copy-of select="$mode"/></td><td class="header"><a href="#" class="minmax ui-icon ui-icon-plusthick" title="Click me to expand">[+]</a></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table>
 
                 <table class="table" border="1">
@@ -254,5 +254,5 @@
                 </tbody>
                 </table>
-        </div><br/>
+        </div>
     </xsl:template>
 
@@ -312,15 +312,15 @@
                     <xsl:choose>
                         <xsl:when test="@type='document'">
-                            <option value = "document" selected = "document">Document</option>
+                            <option value = "document" selected = "selected">Document</option>
                             <option value = "classifier">Classifier</option>
                             <option value = "source">Source</option>
                         </xsl:when>
                         <xsl:when test="@type='classifier'">
-                            <option value = "classifier" selected = "classifier">Classifier</option>
+                            <option value = "classifier" selected = "selected">Classifier</option>
                             <option value = "document">Document</option>
                             <option value = "source">Source</option>
                         </xsl:when>
                         <xsl:when test="@type='source'">
-                            <option value = "source" selected = "source">Source</option>
+                            <option value = "source" selected = "selected">Source</option>
                             <option value ="document">Document</option>
                             <option value ="classifier">Classifier</option>
