Index: /trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java	(revision 6068)
+++ /trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java	(revision 6069)
@@ -231,10 +231,11 @@
        private String value = null;
 
-       private AppendMetadataTask(ElementWrapper element, String value) {
+       private AppendMetadataTask(ElementWrapper element, String raw_value) {
 	  this.element = element;
+	  this.value = raw_value;
 	  // Transform the raw text to be GREENSTONE and DOM compatible - as that will be its next destination immediately after being added to the value model
-	  this.value = Codec.transform(value, Codec.ENCODE_PATH);
-	  this.value = Codec.transform(this.value, Codec.REMOVE_SQUARE_BRACKET);
-	  this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM);
+	  //this.value = /odec.transform(value, /odec.ENCODE_PATH);
+	  //this.value = /odec.transform(this.value, /odec.REMOVE_SQUARE_BRACKET);
+	  //this.value = /odec.transform(this.value, /odec.TEXT_TO_DOM);
        }
 
@@ -267,9 +268,10 @@
        private String value;
 
-	private UpdateMetadataTask(ElementWrapper element, String value) {
+	private UpdateMetadataTask(ElementWrapper element, String raw_value) {
 	  this.element = element;
+	  this.value = raw_value;
 	  // Transform the raw text to be DOM compatible - as that will be its next destination immediately after being added to the value model
-	  this.value = Codec.transform(value, Codec.REMOVE_SQUARE_BRACKET);
-	  this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM);
+	  //this.value = /odec.transform(value, /odec.REMOVE_SQUARE_BRACKET);
+	  //this.value = /odec.transform(this.value, /odec.TEXT_TO_DOM);
 	}
 
@@ -1103,5 +1105,5 @@
 	    JPanel value_field_pane = new JPanel();
 	    TransformCharacterTextField value_init = new TransformCharacterTextField();
-	    value_init.replaceCharacter(StaticStrings.PIPE_CHAR, StaticStrings.FORWARDSLASH_CHAR);
+	    //value_init.replaceCharacter(StaticStrings.PIPE_CHAR, StaticStrings.FORWARDSLASH_CHAR);
 	    value = value_init;
 	    value_init = null;
@@ -1189,5 +1191,10 @@
 
 	public String getSelectedValue() {
-	    return Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_GREENSTONE);
+	    //return /odec.transform(/odec.transformUnicode(value.getText()), /odec.TEXT_TO_GREENSTONE);
+	    String raw_value = value.getText();
+	    raw_value = Codec.transformUnicode(raw_value);
+	    raw_value = Codec.transform(raw_value, Codec.ENCODE_PATH);
+	    raw_value = Codec.transform(raw_value, Codec.ENCODE_SQUARE_BRACKETS);
+	    return raw_value;
 	}
 
@@ -1256,8 +1263,12 @@
 	    // Setting the text of the field causes the DocumentListener to be notified, and
 	    //   updating the tree is handled there (DocumentListenerImpl::validate())
-	    ///ystem.err.println("Setting selected value to: " + val);
 	    if (!card_showing.equals(NONE)) {
+		// Decode val
+		//System.err.println("Before transforms: " + val);
+		//val = Codec.transform(val, Codec.DECODE_SQUARE_BRACKETS);
+		//val = Codec.transform(val, Codec.DECODE_PATH);
+		//System.err.println("Setting selected value to: " + val);
 		manual_text_edit_event = val.equals("");  // Set to false unless val == ""
-		value.setText(Codec.transform(val, Codec.GREENSTONE_TO_TEXT));
+		value.setText(val); ///odec.transform(val, /odec.GREENSTONE_TO_TEXT));
 		value.setCaretPosition(0);
 		manual_text_edit_event = true;
@@ -1269,9 +1280,10 @@
 	private TreePath getClosestPath(String val)
 	{
+	    System.err.println("Select closest path to: " + val);
 	    // Start at the root of the tree
 	    GValueNode tree_node = (GValueNode) tree.getModel().getRoot();
 
-	    // Hierarchical values are separated using '\'
-	    PatternTokenizer tokenizer = new PatternTokenizer(val, "\\");  // StaticStrings.PIPE_STR);
+	    // Hierarchical values are separated using '|'
+	    PatternTokenizer tokenizer = new PatternTokenizer(val, StaticStrings.PIPE_STR);
 	    while (tokenizer.hasMoreTokens()) {
 		String token = tokenizer.nextToken();
@@ -1336,5 +1348,8 @@
 			TreePath path = tree.getSelectionPath();
 			GValueNode node = (GValueNode) path.getLastPathComponent();
-			value.setText(node.getFullPath(true));
+			String val = node.getFullPath(true);
+			System.err.println("Setting value to: " + val);
+			value.setText(val);
+			val = null;
 		    }
 		}
@@ -1374,5 +1389,5 @@
 	    private void validate()
 	    {
-		String value_text = Codec.transform(getSelectedValue(), Codec.TEXT_TO_DOM);
+		String value_text = getSelectedValue(); ///odec.transform(getSelectedValue(), /odec.TEXT_TO_DOM);
 		///ystem.err.println("\n(Validate) Value text: " + value_text);
 
Index: /trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java	(revision 6068)
+++ /trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java	(revision 6069)
@@ -190,10 +190,11 @@
 		String node_value = null;
 		if(model != null && model.isHierarchy()) {
-			node_value = Codec.transform(metadata.getValueNode().getFullPath(false), Codec.TEXT_TO_DOM);
+		    //node_value = /odec.transform(metadata.getValueNode().getFullPath(false), /odec.TEXT_TO_DOM);
+		    node_value = metadata.getValueNode().getFullPath(false);
 		}
 		else {
-			node_value = metadata.getAbsoluteValue();
-		}
-		///ystem.err.println("Creating node in GDMDocument: '" + node_value + "'");
+		    node_value = metadata.getAbsoluteValue();
+		}
+		System.err.println("Creating node in GDMDocument: '" + node_value + "'");
 		metadata_element.appendChild(base_document.createTextNode(node_value));
 		// Retrieve the first description element for this fileset (there should only be one, but I'll play it safe).
@@ -253,172 +254,175 @@
 	return getMetadata(filename, remove, metadatum_so_far, file, append_folder_level, false);
 	}
-	/** Retrieve the metadata associated with the given filename. Keep track of what metadata should be overwritten and what should be accumulated. Also make note of the source file, and remove the metadata if required. Finally if purge is set retrieve every piece of metadata in this file. */
-	public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file, boolean append_folder_level, boolean purge) {
+    /** Retrieve the metadata associated with the given filename. Keep track of what metadata should be overwritten and what should be accumulated. Also make note of the source file, and remove the metadata if required. Finally if purge is set retrieve every piece of metadata in this file. */
+    public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file, boolean append_folder_level, boolean purge) {
 	Gatherer.println("Get metadata for " + filename);
 	ArrayList metadatum = null;
 	if(metadatum_so_far == null) {
-		metadatum = new ArrayList();
+	    metadatum = new ArrayList();
 	}
 	else {
-		metadatum = metadatum_so_far;
+	    metadatum = metadatum_so_far;
 	}
 	try {
-		// Retrieve the document element.
-		Element directorymetadata_element = base_document.getDocumentElement();
-		// Iterate through the filesets, checking the FileName child element against 	the target file's name using regular expression matching.
-		NodeList fileset_elements = directorymetadata_element.getElementsByTagName(FILESET_ELEMENT);
-		for(int i = 0; i < fileset_elements.getLength(); i++) {
+	    // Retrieve the document element.
+	    Element directorymetadata_element = base_document.getDocumentElement();
+	    // Iterate through the filesets, checking the FileName child element against 	the target file's name using regular expression matching.
+	    NodeList fileset_elements = directorymetadata_element.getElementsByTagName(FILESET_ELEMENT);
+	    for(int i = 0; i < fileset_elements.getLength(); i++) {
 		Element fileset_element = (Element) fileset_elements.item(i);
 		NodeList filename_elements = fileset_element.getElementsByTagName(FILENAME_ELEMENT);
 		for(int j = 0; j < filename_elements.getLength(); j++) {
-			Element filename_element = (Element) filename_elements.item(j);
-			String filename_text = MSMUtils.getValue(filename_element);
-			if((filename != null && (filename.matches(filename_text) || (append_folder_level && filename.indexOf(File.separator) != -1 && filename_text.equals(filename.substring(0, filename.indexOf(File.separator)))))) || ((filename == null || append_folder_level) && filename_text.equals(DIRECTORY_FILENAME)) || purge) {
+		    Element filename_element = (Element) filename_elements.item(j);
+		    String filename_text = MSMUtils.getValue(filename_element);
+		    if((filename != null && (filename.matches(filename_text) || (append_folder_level && filename.indexOf(File.separator) != -1 && filename_text.equals(filename.substring(0, filename.indexOf(File.separator)))))) || ((filename == null || append_folder_level) && filename_text.equals(DIRECTORY_FILENAME)) || purge) {
 			// If they match add all of the metadata found in the Description child element, remembering to abide by desired mode (accumulate vs. overwrite).
 			// Normal metadata
 			NodeList description_elements = fileset_element.getElementsByTagName(DESCRIPTION_ELEMENT);
 			for(int k = 0; k < description_elements.getLength(); k++) {
-				Element description_element = (Element) description_elements.item(k);
-				// We have to do this for each type of metadata
-				for(int z = 0; z < ALL_METADATA_TYPES.length; z++) {
-					NodeList metadata_elements = description_element.getElementsByTagName(ALL_METADATA_TYPES[z]);
-					for(int l = 0; l < metadata_elements.getLength(); l++) {
-						 Element metadata_element = (Element) metadata_elements.item(l);
-						 String raw_element = metadata_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
-						 //String language = metadata_element.getAttribute("language");
-						 String mode = metadata_element.getAttribute(MODE_ATTRIBUTE);
-						 String raw_value = MSMUtils.getValue(metadata_element);
-						 // Raw value is in GREENSTONE form, convert to DOM
-						 raw_value = Codec.transform(raw_value, Codec.GREENSTONE_TO_DOM);
-						 // ***** LEGACY SUPPORT *****
-						 // If this raw_value contains a '\' character, but no '\\', '[' or ']' characters, then replace the '\' with a '\\'
-						 if(raw_value.indexOf(StaticStrings.ESCAPE_STR) != -1) {
-							 Gatherer.println("Detected Legacy Path: " + raw_value);
-							 raw_value = raw_value.replaceAll(StaticStrings.ESCAPE_PATTERN, StaticStrings.PIPE_STR);
-							 Gatherer.println("Updated Path To: " + raw_value);
-							 MSMUtils.setValue(metadata_element, raw_value);
-						 }
-						 // **************************
-						 // Using the element string and value, retrieve a matching Metadata object from the cache
-						 Metadata metadata = null;
-						 // If this element has hierarchy values then we must ensure the raw value is a full path, not an index.
-						 // Try to retrieve an already comstructed piece of metadata from file - but not if we are purging, as this will stuff up anything that is still using that metadata - such as the GTable
-						 if(GDMManager.metadata_cache.contains(raw_element, raw_value) && !purge) {
-							 ///ystem.err.println("HIT! Retrieve metadata from cache: " + raw_element + " -> " + raw_value + "\n");
-							 metadata = (Metadata) GDMManager.metadata_cache.get(raw_element, raw_value);
-						 }
-						 else {
-							 ElementWrapper element = Gatherer.c_man.getCollection().msm.getElement(raw_element);
-							 if (element != null) {
-								 GValueNode value = Metadata.getDefaultValueNode(element, raw_value);
-								 ///ystem.err.println("Miss. Create new metadata: " + raw_element + " -> " + raw_value + "\n");
-								 metadata = new Metadata(element, value);
-								 if(!purge) {
-									 GDMManager.metadata_cache.put(raw_element, raw_value, metadata);
-								 }
-								 ///ystem.err.println("Added metadata to cache: " + raw_element + " -> " + raw_value + "\n");
-								 value = null;
-								 element = null;
-							 }
-						 }
-						 // check whether the metadata is null
-						 if (metadata != null) {
-							 // We determine whether this metadata is file or folder level
-							 if(filename != null) {
-								 ///ystem.err.println("Filename	  = " + filename);
-								 ///ystem.err.println("filename_text = " + filename_text);
-								 // If can only be file level if there is no folder path details in filename and if the filename matched the filename text node (it may have matched .* instead)!
-								 if(filename.indexOf(File.separator) == -1 && filename.equals(filename_text)) {
-									 metadata.setFileLevel(true);
-									 ///ystem.err.println("File level!!!");
-								 }
-								 else {
-									 metadata.setFileLevel(false);
-									 ///ystem.err.println("Inherited!!!");
-								 }
-							 }
-							 else {
-								 ///ystem.err.println("Filename is null therefore this is file level metadata.");
-								 metadata.setFileLevel(true);
-							 }
-							 metadata.setFile(file);
-							 // If mode is overwrite, then remove any previous values for this metadata element.
-							 if(mode.equals("accumulate")) {
-								 metadata.setAccumulate(true);
-							 }
-							 else {
-								 metadata.setAccumulate(false);
-								 ///ystem.err.println("Metadata overwrites: " + metadata);
-								 for(int m = metadatum.size() - 1; m >= 0; m--) {
-									 Metadata old_metadata = (Metadata) metadatum.get(m);
-									 if(old_metadata.getElement().equals(metadata.getElement())) {
-										 metadatum.remove(m);
-										 ///ystem.err.println("Removing overridden metadata: " + old_metadata);
-									 }
-									 old_metadata = null;
-								 }
-							 }
-							 mode = null;
-							 // Add the completed metadata and clean up
-							 ///ystem.err.println("Adding metadata: " + metadata);
-							 metadatum.add(metadata);
-							 // Having found our metadata check if the value from the xml matches the one from the gvaluenode. If not update it. This happens whenever hierarchy information is involved (indexes rapidly become obsolete).
-							 // If remove was set, remove it. We can only remove pure file level metadata, or folder level iff we were asked for folder level.
-							 if(remove && ((filename != null && filename.matches(filename_text) && !filename_text.equals(DIRECTORY_FILENAME)) || (filename == null && filename_text.equals(DIRECTORY_FILENAME)))) {
-								 ///ystem.err.println("Removing " + metadata + " from " + file);
-								 description_element.removeChild(metadata_element);
-								 // Remove the description element if empty.
-								 if(!description_element.hasChildNodes()) {
-									 fileset_element.removeChild(description_element);
-								 }
-							 }
-							 else {
-								 //String current_value = metadata.getAbsoluteValue();
-								 String current_value = Codec.transform(metadata.getValueNode().getFullPath(false), Codec.TEXT_TO_DOM);
-								 ///ystem.err.println("Checking the current hfile: " + current_value);
-								 ///ystem.err.println("Against whats in the hfile: " + current_value);
-								 if(!raw_value.equals(current_value)) {
-									 // Remove old text
-									 while(metadata_element.hasChildNodes()) {
-										 metadata_element.removeChild(metadata_element.getFirstChild());
-									 }
-									 // Add new.
-									 metadata_element.appendChild(base_document.createTextNode(current_value));
-								 }
-							 }
-						 }
-						 metadata = null;
-						 raw_value = null;
-						 raw_element = null;
-						 metadata_element = null;
-					 }
-					 metadata_elements = null;
+			    Element description_element = (Element) description_elements.item(k);
+			    // We have to do this for each type of metadata
+			    for(int z = 0; z < ALL_METADATA_TYPES.length; z++) {
+				NodeList metadata_elements = description_element.getElementsByTagName(ALL_METADATA_TYPES[z]);
+				for(int l = 0; l < metadata_elements.getLength(); l++) {
+				    Element metadata_element = (Element) metadata_elements.item(l);
+				    String raw_element = metadata_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
+				    //String language = metadata_element.getAttribute("language");
+				    String mode = metadata_element.getAttribute(MODE_ATTRIBUTE);
+				    String raw_value = MSMUtils.getValue(metadata_element);
+				    // 
+				    //raw_value = Codec.transform(raw_value, Codec.DOM_TO_);
+				    ///ystem.err.println("Retrieved raw value: " + raw_value);
+				    // ***** LEGACY SUPPORT *****
+				    // If this raw_value contains a '\' character, but no '\\', '[' or ']' characters, then replace the '\' with a '\\'
+				    if(raw_value.indexOf(StaticStrings.ESCAPE_STR) != -1) {
+					///ystem.err.println("Blarg");
+					Gatherer.println("Detected Legacy Path: " + raw_value);
+					raw_value = raw_value.replaceAll(StaticStrings.ESCAPE_PATTERN, StaticStrings.PIPE_STR);
+					Gatherer.println("Updated Path To: " + raw_value);
+					MSMUtils.setValue(metadata_element, raw_value);
+				    }
+				    // **************************
+				    // Using the element string and value, retrieve a matching Metadata object from the cache
+				    Metadata metadata = null;
+				    // If this element has hierarchy values then we must ensure the raw value is a full path, not an index.
+				    // Try to retrieve an already comstructed piece of metadata from file - but not if we are purging, as this will stuff up anything that is still using that metadata - such as the GTable
+				    if(GDMManager.metadata_cache.contains(raw_element, raw_value) && !purge) {
+					///ystem.err.println("HIT! Retrieve metadata from cache: " + raw_element + " -> " + raw_value + "\n");
+					metadata = (Metadata) GDMManager.metadata_cache.get(raw_element, raw_value);
+				    }
+				    else {
+					ElementWrapper element = Gatherer.c_man.getCollection().msm.getElement(raw_element);
+					if (element != null) {
+					    GValueNode value = Metadata.getDefaultValueNode(element, raw_value);
+					    ///ystem.err.println("Miss. Create new metadata: " + raw_element + " -> " + raw_value + "\n");
+					    metadata = new Metadata(element, value);
+					    if(!purge) {
+						GDMManager.metadata_cache.put(raw_element, raw_value, metadata);
+					    }
+					    ///ystem.err.println("Added metadata to cache: " + raw_element + " -> " + raw_value + "\n");
+					    value = null;
+					    element = null;
+					}
+				    }
+				    // check whether the metadata is null
+				    if (metadata != null) {
+					// We determine whether this metadata is file or folder level
+					if(filename != null) {
+					    ///ystem.err.println("Filename	  = " + filename);
+					    ///ystem.err.println("filename_text = " + filename_text);
+					    // If can only be file level if there is no folder path details in filename and if the filename matched the filename text node (it may have matched .* instead)!
+					    if(filename.indexOf(File.separator) == -1 && filename.equals(filename_text)) {
+						metadata.setFileLevel(true);
+						///ystem.err.println("File level!!!");
+					    }
+					    else {
+						metadata.setFileLevel(false);
+						///ystem.err.println("Inherited!!!");
+					    }
+					}
+					else {
+					    ///ystem.err.println("Filename is null therefore this is file level metadata.");
+					    metadata.setFileLevel(true);
+					}
+					metadata.setFile(file);
+					// If mode is overwrite, then remove any previous values for this metadata element.
+					if(mode.equals("accumulate")) {
+					    metadata.setAccumulate(true);
+					}
+					else {
+					    metadata.setAccumulate(false);
+					    ///ystem.err.println("Metadata overwrites: " + metadata);
+					    for(int m = metadatum.size() - 1; m >= 0; m--) {
+						Metadata old_metadata = (Metadata) metadatum.get(m);
+						if(old_metadata.getElement().equals(metadata.getElement())) {
+						    metadatum.remove(m);
+						    ///ystem.err.println("Removing overridden metadata: " + old_metadata);
+						}
+						old_metadata = null;
+					    }
+					}
+					mode = null;
+					// Add the completed metadata and clean up
+					///ystem.err.println("Adding metadata: " + metadata);
+					metadatum.add(metadata);
+					// Having found our metadata check if the value from the xml matches the one from the gvaluenode. If not update it. This happens whenever hierarchy information is involved (indexes rapidly become obsolete).
+					// If remove was set, remove it. We can only remove pure file level metadata, or folder level iff we were asked for folder level.
+					if(remove && ((filename != null && filename.matches(filename_text) && !filename_text.equals(DIRECTORY_FILENAME)) || (filename == null && filename_text.equals(DIRECTORY_FILENAME)))) {
+					    ///ystem.err.println("Removing " + metadata + " from " + file);
+					    description_element.removeChild(metadata_element);
+					    // Remove the description element if empty.
+					    if(!description_element.hasChildNodes()) {
+						fileset_element.removeChild(description_element);
+					    }
+					}
+					else {
+					    //String current_value = metadata.getAbsoluteValue();
+					    //String current_value = Codec.transform(metadata.getValueNode().getFullPath(false), Codec.TEXT_TO_DOM);
+					    String current_value = metadata.getValueNode().getFullPath(false);
+					    //System.err.println("Checking the current mdv path: " + current_value);
+					    //System.err.println("Against whats in the metadata file: " + raw_value);
+					    if(!raw_value.equals(current_value)) {
+						// Remove old text
+						while(metadata_element.hasChildNodes()) {
+						    metadata_element.removeChild(metadata_element.getFirstChild());
+						}
+						// Add new.
+						metadata_element.appendChild(base_document.createTextNode(current_value));
+					    }
+					}
+				    }
+				    metadata = null;
+				    raw_value = null;
+				    raw_element = null;
+				    metadata_element = null;
 				}
-				description_element = null;
+				metadata_elements = null;
+			    }
+			    description_element = null;
 			}
 			description_elements = null;
-			}
-			filename_text = null;
-			filename_element = null;
+		    }
+		    filename_text = null;
+		    filename_element = null;
 		}
 		// If the file set no longer has any description entries, remove it entirely
 		NodeList description_elements = fileset_element.getElementsByTagName(DESCRIPTION_ELEMENT);
 		if(description_elements.getLength() == 0) {
-			directorymetadata_element.removeChild(fileset_element);
+		    directorymetadata_element.removeChild(fileset_element);
 		}
 		description_elements = null;
 		filename_elements = null;
 		fileset_element = null;
-		}
-		fileset_elements = null;
-		directorymetadata_element = null;
+	    }
+	    fileset_elements = null;
+	    directorymetadata_element = null;
 	}
 	catch (Exception error) {
-		Gatherer.self.printStackTrace(error);
+	    Gatherer.self.printStackTrace(error);
 	}
 	///ystem.err.println("Found " + metadatum.size() + " pieces of metadata.");
 	return metadatum;
-	}
-
+    }
+    
 	/** Determine if this document has been saved recently, and thus xml file version is up to date. */
 	public boolean isUpToDate() {
Index: /trunk/gli/src/org/greenstone/gatherer/util/Codec.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/util/Codec.java	(revision 6068)
+++ /trunk/gli/src/org/greenstone/gatherer/util/Codec.java	(revision 6069)
@@ -37,23 +37,23 @@
  */
 public class Codec {
-
+    
     static final public String DECODE_PATH = "DECODE_PATH";
-   static final public String DOM_TO_GREENSTONE = "DOM_TO_GREENSTONE";
-   static final public String DOM_TO_TEXT = "DOM_TO_TEXT";
+    static final public String DECODE_SQUARE_BRACKETS = "DECODE_SQUARE_BRACKETS";
+    static final public String DOM_TO_GREENSTONE = "DOM_TO_GREENSTONE";
+    static final public String DOM_TO_TEXT = "DOM_TO_TEXT";
     static final public String ENCODE_PATH = "ENCODE_PATH";
-   static final public String GREENSTONE_TO_DOM = "GREENSTONE_TO_DOM";
-   static final public String GREENSTONE_TO_TEXT = "GREENSTONE_TO_TEXT";
-   static final public String REMOVE_SQUARE_BRACKET = "REMOVE_SQUARE_BRACKET";
-   static final public String TEXT_TO_DOM = "TEXT_TO_DOM";
-   static final public String TEXT_TO_GREENSTONE = "TEXT_TO_GREENSTONE";
-   static final public String TEXT_TO_SHELL_UNIX = "TEXT_TO_SHELL_UNIX";
-   static final public String TEXT_TO_SHELL_WINDOWS = "TEXT_TO_SHELL_WINDOWS";
-
+    static final public String ENCODE_SQUARE_BRACKETS = "ENCODE_SQUARE_BRACKETS";
+    static final public String GREENSTONE_TO_DOM = "GREENSTONE_TO_DOM";
+    static final public String GREENSTONE_TO_TEXT = "GREENSTONE_TO_TEXT";
+    static final public String TEXT_TO_DOM = "TEXT_TO_DOM";
+    static final public String TEXT_TO_GREENSTONE = "TEXT_TO_GREENSTONE";
+    static final public String TEXT_TO_SHELL_UNIX = "TEXT_TO_SHELL_UNIX";
+    static final public String TEXT_TO_SHELL_WINDOWS = "TEXT_TO_SHELL_WINDOWS";
+    
     static final private int MAX_CACHE_SIZE = 100;
-
+    
     static private HashMap TRANSFORMS;
     static private HashMap3D CACHE;
-
-
+    
     /** Static function called to construct TRANSFORMS mappings */
     static {
@@ -61,8 +61,17 @@
 
 	String[] decode_path = {
-	    "\\|", "\\\\"
+	    "\\|",    "\\\\",
+	    "&#124;", "\\|"
 	};
 	TRANSFORMS.put(DECODE_PATH, decode_path);
 	decode_path = null;
+
+	// Transform text into text, but without [ and ]
+	String[] decode_square_brackets = {
+	    "&#091;", "\\[",
+	    "&#093;", "\\]" 
+	};
+	TRANSFORMS.put(DECODE_SQUARE_BRACKETS, decode_square_brackets);
+	decode_square_brackets = null;
 
 	// Translate DOM encoded text into Greenstone encoding
@@ -94,8 +103,17 @@
 
 	String[] encode_path = {
+	    "\\|",  "&#124;",
 	    "\\\\", "\\|"
 	};
 	TRANSFORMS.put(ENCODE_PATH, encode_path);
 	encode_path = null;
+
+	// Transform text into text, but without [ and ]
+	String[] encode_square_brackets = {
+	    "\\[", "&#091;",
+	    "\\]", "&#093;"
+	};
+	TRANSFORMS.put(ENCODE_SQUARE_BRACKETS, encode_square_brackets);
+	encode_square_brackets = null;
 
 	// Transform Greenstone encoded text to DOM encoding
@@ -125,12 +143,4 @@
 	TRANSFORMS.put(GREENSTONE_TO_TEXT, greenstone_to_text);
 	greenstone_to_text = null;
-
-	// Transform text into text, but without [ and ]
-	String[] remove_square_bracket = {
-	    "\\[", "&amp;#091;",
-	    "\\]", "&amp;#093;"
-	};
-	TRANSFORMS.put(REMOVE_SQUARE_BRACKET, remove_square_bracket);
-	remove_square_bracket = null;
 
 	// Transform plain html text into something that can be placed in a DOM
Index: /trunk/gli/src/org/greenstone/gatherer/util/MetadataXML.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/util/MetadataXML.java	(revision 6068)
+++ /trunk/gli/src/org/greenstone/gatherer/util/MetadataXML.java	(revision 6069)
@@ -59,5 +59,5 @@
  		String index = model.getHIndex(full_value);
 
-		write(bw, "\"" + Utility.stripNL(full_value) + "\"\t" + index + "\t\"" + Utility.stripNL(node.toString()) + "\"");
+		write(bw, "\"" + Utility.stripNL(full_value) + "\"\t" + index + "\t\"" + Utility.stripNL(node.toString(GValueNode.GREENSTONE)) + "\"");
 	    }
 	    // Very important we do this, or else buffer may not have
Index: /trunk/gli/src/org/greenstone/gatherer/valuetree/GValueModel.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/valuetree/GValueModel.java	(revision 6068)
+++ /trunk/gli/src/org/greenstone/gatherer/valuetree/GValueModel.java	(revision 6069)
@@ -251,8 +251,8 @@
 
     private String getHIndex(GValueNode node, String value, String index) {
-		///ystem.err.println("Get the HIndex for: " + value);
+	///ystem.err.println("Get the HIndex for: " + value);
 	for(int i = node.size(); i != 0; i--) {
 	    GValueNode next = (GValueNode)node.get(i - 1);
-	    String next_str = next.toString();
+	    String next_str = next.toString(GValueNode.DOM);
 	    ///ystem.err.println("Does " + value + " start with " + next_str + "?");
 	    if(value.startsWith(next_str)) {
Index: /trunk/gli/src/org/greenstone/gatherer/valuetree/GValueNode.java
===================================================================
--- /trunk/gli/src/org/greenstone/gatherer/valuetree/GValueNode.java	(revision 6068)
+++ /trunk/gli/src/org/greenstone/gatherer/valuetree/GValueNode.java	(revision 6069)
@@ -162,14 +162,18 @@
 	    return default_value;
 	}
-	StringBuffer path = new StringBuffer(toString());
+	StringBuffer path = new StringBuffer(toString(DOM));
 	GValueNode node = (GValueNode) getParent();
 	while(node != null && !node.getElement().getNodeName().equalsIgnoreCase("AssignedValues")) {
 	    path.insert(0, StaticStrings.PIPE_STR);
-	    path.insert(0, node.toString());
+	    path.insert(0, node.toString(DOM));
 	    node = (GValueNode) node.getParent();
 	}
 	if(as_text) {
-	    String temp = Codec.transform(path.toString(), Codec.GREENSTONE_TO_TEXT);
-	    return Codec.transform(temp, Codec.DECODE_PATH);
+	    String temp = path.toString(); ///odec.transform(path.toString(), codec.GREENSTONE_TO_TEXT);
+	    System.err.println("Raw: " + temp);
+	    temp = Codec.transform(temp, Codec.DECODE_PATH);
+	    temp = Codec.transform(temp, Codec.DECODE_SQUARE_BRACKETS);
+	    System.err.println("Decoded: " + temp);
+	    return temp;
 	}
 	else {
@@ -313,21 +317,22 @@
 	String result = null;
 	if(name.equals("Subject")) {
-	   result = MSMUtils.getValue(element);
-	   result = Codec.transform(result, Codec.DECODE_PATH);
-	   switch(decode_type) {
-	      case GValueNode.GREENSTONE:
-		 // We want this as greenstone format
-		 ///ystem.err.print(result);
-		 result = Codec.transform(result, Codec.DOM_TO_GREENSTONE);
-		 ///ystem.err.println(" -> D2G decode -> " + result);
-		 break;
-	      case GValueNode.TEXT:
-		 ///ystem.err.print(result);
-		 result = Codec.transform(result, Codec.DOM_TO_TEXT);
-		 ///ystem.err.println(" -> D2T decode -> " + result);
-		 break;
-	      default:
-		 ///ystem.err.println(result + " -> nothing to do.");
-	   }
+	    result = MSMUtils.getValue(element);
+	    ///ystem.err.print(result);
+	    switch(decode_type) {
+	    case GValueNode.GREENSTONE:
+		// We want this as greenstone format
+		///ystem.err.print(result);
+		//result = /odec.transform(result, /odec.DOM_TO_GREENSTONE);
+		///ystem.err.println(" -> D2G decode -> " + result);
+		break;
+	    case GValueNode.TEXT:
+		//result = /odec.transform(result, /odec.DOM_TO_TEXT);
+		result = Codec.transform(result, Codec.DECODE_PATH);
+		result = Codec.transform(result, Codec.DECODE_SQUARE_BRACKETS);
+		///ystem.err.println(" -> D2T decode -> " + result);
+		break;
+	    default:
+		///ystem.err.println(result + " -> nothing to do.");
+	    }
 	}
 	else if(name.equals("AssignedValues")) {
