Changeset 18308


Ignore:
Timestamp:
2009-01-05T21:20:32+13:00 (15 years ago)
Author:
kjdon
Message:

added a couple of getInterfaceTextWithDOM methods - can pass in DOM args to the dictionary - will do a pretty print of the xml and use it as an argument

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/util/XSLTUtil.java

    r16869 r18308  
    2626
    2727import org.apache.log4j.*;
     28import org.w3c.dom.Node;
    2829
    2930/** a class to contain various static methods that are used by the xslt
     
    132133        if (result == null) { // not found
    133134                return "_"+key+"_";
     135        }
     136        return result;
     137    }
     138
     139    public static String getInterfaceTextWithDOM(String interface_name, String lang, String key, Node arg_node) {
     140    String [] args = new String [1];
     141 
     142    String node_str = XMLConverter.getString(arg_node);
     143    args[0] = node_str;
     144    Dictionary dict = new Dictionary("interface_"+interface_name, lang);
     145    String result = dict.get(key, args);
     146    if (result == null) { // not found
     147        //if not found, search a separate subdirectory named by the interface name
     148        String sep_interface_dir = interface_name + File.separatorChar + lang + File.separatorChar + "interface";
     149        dict = new Dictionary(sep_interface_dir, lang);
     150        result = dict.get(key, args);
     151        if(result != null) {
     152        return result;
     153        }   
     154    }
     155
     156    if (result == null && !interface_name.equals("default")) { // not found, try the default interface
     157        dict = new Dictionary("interface_default", lang);
     158        result = dict.get(key, args);
     159    }
     160       
     161        if (result == null) { // not found
     162                return "_"+key+"_";
    134163        }
     164
     165        return result;
     166    }
     167    public static String getInterfaceTextWithDOM(String interface_name, String lang, String key, Node arg1_node, Node arg2_node) {
     168    String [] args = new String [2];
     169 
     170    String node_str = XMLConverter.getString(arg1_node);
     171    args[0] = node_str;
     172    node_str = XMLConverter.getString(arg2_node);
     173    args[1] = node_str;
     174    Dictionary dict = new Dictionary("interface_"+interface_name, lang);
     175    String result = dict.get(key, args);
     176    if (result == null) { // not found
     177        //if not found, search a separate subdirectory named by the interface name
     178        String sep_interface_dir = interface_name + File.separatorChar + lang + File.separatorChar + "interface";
     179        dict = new Dictionary(sep_interface_dir, lang);
     180        result = dict.get(key, args);
     181        if(result != null) {
     182        return result;
     183        }   
     184    }
     185
     186    if (result == null && !interface_name.equals("default")) { // not found, try the default interface
     187        dict = new Dictionary("interface_default", lang);
     188        result = dict.get(key, args);
     189    }
     190       
     191        if (result == null) { // not found
     192                return "_"+key+"_";
     193        }
     194   
    135195        return result;
    136196    }
Note: See TracChangeset for help on using the changeset viewer.