Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java	(revision 33294)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java	(revision 33295)
@@ -222,11 +222,9 @@
 	public static String getInterfaceText(String interface_name, String lang, String key)
 	{
-		return getInterfaceText(interface_name, lang, key, null);
+		return getInterfaceTextWithArgs(interface_name, lang, key, null);
 	}
 
 	public static String getInterfaceText(String interface_name, String lang, String key, String args_str)
 	{
-		key = key.replaceAll("__INTERFACE_NAME__", interface_name);
-
 		String[] args = null;
 		if (args_str != null && !args_str.equals(""))
@@ -234,42 +232,9 @@
 			args = StringUtils.split(args_str, ";");
 		}
-		Dictionary dict = new Dictionary("interface_" + interface_name, lang);
-		String result = dict.get(key, args);
-		if (result == null)
-		{ // not found
-			//if not found, search a separate subdirectory named by the interface name
-			String sep_interface_dir = interface_name + File.separatorChar + lang + File.separatorChar + "interface";
-			dict = new Dictionary(sep_interface_dir, lang);
-			result = dict.get(key, args);
-			if (result != null)
-			{
-				result = result.replaceAll("__INTERFACE_NAME__", interface_name);
-				return result;
-			}
-		}
-
-		if (result == null && !interface_name.startsWith("default"))
-		{ // not found, try the default interface
-		  if (interface_name.endsWith("2")) { // hack for interface_xxx2.properties
-		    dict = new Dictionary("interface_default2", lang);
-		  } else {
-		    dict = new Dictionary("interface_default", lang);
-
-		  }
-		  result = dict.get(key, args);
-		}
-		
-		if (result == null)
-		{ // not found
-			return "_" + key + "_";
-		}
-		result = result.replaceAll("__INTERFACE_NAME__", interface_name);
-		return result;
-	}
-
-	public static String getInterfaceText(String interfaceName, String dictionaryName, String lang, String key, String args_str)
-	{
-		key = key.replaceAll("__INTERFACE_NAME__", interfaceName);
-
+		return getInterfaceTextWithArgs(interface_name, lang, key, args);
+	}
+  
+	public static String getInterfaceText(String interface_name, String dictionary_name, String lang, String key, String args_str)
+	{
 		String[] args = null;
 		if (args_str != null && !args_str.equals(""))
@@ -277,104 +242,86 @@
 			args = StringUtils.split(args_str, ";");
 		}
-		Dictionary dict = new Dictionary(dictionaryName, lang);
-		String result = dict.get(key, args);
-		if (result == null)
-		{ // not found
-			//if not found, search a separate subdirectory named by the interface name
-			String sep_interface_dir = interfaceName + File.separatorChar + lang + File.separatorChar + "interface";
-			dict = new Dictionary(sep_interface_dir, lang);
-			result = dict.get(key, args);
-			if (result != null)
-			{
-				result = result.replaceAll("__INTERFACE_NAME__", interfaceName);
-				return result;
-			}
-		}
-
-		if (result == null && !interfaceName.equals("default"))
-		{ // not found, try the default interface
-			dict = new Dictionary("interface_default", lang);
-			result = dict.get(key, args);
-		}
-
-		if (result == null)
-		{ // not found
-			return "_" + key + "_";
-		}
-		result = result.replaceAll("__INTERFACE_NAME__", interfaceName);
+
+		// try the specified dictionary first
+		Dictionary dict = new Dictionary(dictionary_name, lang);
+	 	String result = dict.get(key, args);
+	 	if (result == null) {
+		  // fall back to a general interface text search
+		  return getInterfaceTextWithArgs(interface_name, lang, key, args);
+		}
+		result = result.replaceAll("__INTERFACE_NAME__", interface_name); // do we need to so this here?
 		return result;
 	}
-
+  
 	public static String getInterfaceTextWithDOM(String interface_name, String lang, String key, Node arg_node)
 	{
-		String[] args = new String[1];
-
-		String node_str = XMLConverter.getString(arg_node);
-		args[0] = node_str;
-		Dictionary dict = new Dictionary("interface_" + interface_name, lang);
-		String result = dict.get(key, args);
-		if (result == null)
-		{ // not found
-			//if not found, search a separate subdirectory named by the interface name
-			String sep_interface_dir = interface_name + File.separatorChar + lang + File.separatorChar + "interface";
-			dict = new Dictionary(sep_interface_dir, lang);
-			result = dict.get(key, args);
-			if (result != null)
-			{
-				return result;
-			}
-		}
-
-		if (result == null && !interface_name.equals("default"))
-		{ // not found, try the default interface
-			dict = new Dictionary("interface_default", lang);
-			result = dict.get(key, args);
-		}
-
-		if (result == null)
-		{ // not found
-			return "_" + key + "_";
-		}
-
-		return result;
+	  return getInterfaceTextWithDOMMulti(interface_name, lang, key, arg_node);
 	}
 
 	public static String getInterfaceTextWithDOM(String interface_name, String lang, String key, Node arg1_node, Node arg2_node)
 	{
-		String[] args = new String[2];
-
-		String node_str = XMLConverter.getString(arg1_node);
-		args[0] = node_str;
-		node_str = XMLConverter.getString(arg2_node);
-		args[1] = node_str;
-		Dictionary dict = new Dictionary("interface_" + interface_name, lang);
-		String result = dict.get(key, args);
-		if (result == null)
-		{ // not found
-			//if not found, search a separate subdirectory named by the interface name
-			String sep_interface_dir = interface_name + File.separatorChar + lang + File.separatorChar + "interface";
-			dict = new Dictionary(sep_interface_dir, lang);
-			result = dict.get(key, args);
-			if (result != null)
-			{
-				return result;
-			}
-		}
-
-		if (result == null && !interface_name.equals("default"))
-		{ // not found, try the default interface
-			dict = new Dictionary("interface_default", lang);
-			result = dict.get(key, args);
-		}
-
-		if (result == null)
-		{ // not found
-			return "_" + key + "_";
-		}
-
-		return result;
-	}
-
-
+	  return getInterfaceTextWithDOMMulti(interface_name, lang, key, arg1_node, arg2_node);
+	}
+
+  public static String getInterfaceTextWithDOMMulti(String interface_name, String lang, String key, Node... nodes)
+  {
+    int num_nodes = nodes.length;
+    String[] args = null;
+    if (num_nodes != 0)
+      {
+	args = new String[num_nodes];
+	
+	for (int i = 0; i < num_nodes; i++)
+	  {
+	    String node_str = XMLConverter.getString(nodes[i]);
+	    args[i] = node_str;
+	  }
+      }
+    return getInterfaceTextWithArgs(interface_name, lang, key, args);
+
+  }
+
+  /* This is the base method that actually does the work of looking up the various chain of dictionaries */
+  public static String getInterfaceTextWithArgs(String interface_name, String lang, String key, String[] args)
+  {
+    Dictionary dict = new Dictionary("interface_" + interface_name, lang);
+    
+    // do we need this?? values can have __INTERFACE_NAME__ but would keys ever have it???
+    key = key.replaceAll("__INTERFACE_NAME__", interface_name);
+    String result = dict.get(key, args);
+    if (result == null)
+      { // not found - TODO delete this???
+	//if not found, search a separate subdirectory named by the interface name
+	String sep_interface_dir = interface_name + File.separatorChar + lang + File.separatorChar + "interface";
+	dict = new Dictionary(sep_interface_dir, lang);
+	result = dict.get(key, args);
+	if (result != null)
+	  {
+	    return result;
+	  }
+      }
+
+    if (result == null && !interface_name.startsWith("default")) {
+      // not found, try the default interface
+      if (interface_name.endsWith("2")) { // hack for interface_xxx2.properties
+	dict = new Dictionary("interface_default2", lang);
+      } else {
+	dict = new Dictionary("interface_default", lang);
+	
+      }
+      result = dict.get(key, args);
+    }
+		
+    if (result == null)
+      { // not found
+	return "?" + key + "?";
+      }
+    result = result.replaceAll("__INTERFACE_NAME__", interface_name);
+
+    return result;
+
+
+
+  }
     	public static String getInterfaceTextSubstituteArgs(String value, String args_str)
 	{
@@ -464,7 +411,19 @@
 
   public static String getGenericText(String dictionary_name, String lang, String key) {
-
+    return getGenericTextWithArgs(dictionary_name, lang, key, null);
+  }
+
+  public String getGenericText(String dictionary_name, String lang, String key, String args_str) {
+    String[] args = null;
+    if (args_str != null && !args_str.equals("")) {
+      args = StringUtils.split(args_str, ";");
+    }
+    return getGenericTextWithArgs(dictionary_name, lang, key, args);
+  }
+
+  public static String getGenericTextWithArgs(String dictionary_name, String lang, String key, String[] args)
+  {
     Dictionary dict = new Dictionary(dictionary_name, lang);
-    String result = dict.get(key);
+    String result = dict.get(key, args);
     if (result == null) {
       return "_"+dictionary_name+"_"+key+"_";
@@ -472,4 +431,7 @@
     return result;
   }
+
+
+  
 	public static boolean isImage(String mimetype)
 	{
