Changeset 3850 for trunk/gsdl3


Ignore:
Timestamp:
2003-03-11T16:53:23+13:00 (21 years ago)
Author:
kjdon
Message:

added more stuff

File:
1 edited

Legend:

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

    r3818 r3850  
    3535    public static final String ERROR_ELEM = "error";
    3636    public static final String DEFAULT_ELEM = "default";
    37     public static final String STYLESHEET_ELEM = "stylesheet"; // any additional stylesheet stuff is carried in the message inside this elem
     37    public static final String STYLESHEET_ELEM = "format";//"stylesheet"; // any additional stylesheet stuff is carried in the message inside this elem
     38    public static final String FORMAT_ELEM = "format"; // config files use format - shoudl we use this instead of stylesheet??
    3839    public static final String TERM_ELEM = "term";
    3940
     41    //config file elems
     42    public static final String INDEX_ELEM = "index";
     43    public static final String SEARCH_ELEM = "search";
     44    public static final String BROWSE_ELEM = "browse";
     45    public static final String FIELD_ELEM = "field";
     46    public static final String DISPLAYNAME_ELEM = "displayName";
     47    public static final String SHORTNAME_ATT = "shortname";
    4048    // elems for the pages to be processed by xslt
    4149    public final static String PAGE_ELEM = "page";
     
    6674    public static final String PARAM_SHORTNAME_ATT = "shortname";
    6775    public static final String PARAM_IGNORE_POS_ATT = "ignore";
    68 
     76    public static final String CLASSIFIER_CONTENT_ATT = "content";
    6977    public static final String DOC_NODE_ELEM = "documentNode";
    7078    public static final String DOC_NODE_ID_ATT = "documentID";
     
    7987    public static final String PARAM_TYPE_INTEGER = "integer";
    8088    public static final String PARAM_TYPE_BOOLEAN = "boolean";
    81     public static final String PARAM_TYPE_ENUM = "enum";
     89    public static final String PARAM_TYPE_ENUM_START = "enum";
    8290    public static final String PARAM_TYPE_ENUM_SINGLE = "enum_single";
    8391    public static final String PARAM_TYPE_ENUM_MULTI = "enum_multi";
     
    119127   
    120128    // takes a node with a resource elements inside it and extracts all the
    121     // HASh oids - name att for resource
     129    // HASH oids - name att for resource
     130    // generalise this for any element type? pass in the list, the element name, the att to extract
    122131    public static String [] getDocumentNameList(Element content) {
    123132   
     
    147156    }
    148157
     158    // same as above function
    149159    /** extracts metadata names out of an element */
    150160    public static String [] getMetaNameList(Element content) {
     
    170180    }
    171181
     182    // combine the next two??
    172183    /** takes a paramList element, and gets a HashMap of name-value pairs */
    173184    public static HashMap extractParams(Element xml) {
     
    213224    }
    214225
     226    /** gets the value att or the text content */
    215227    public static String getValue(Element e) {
    216228    String val = e.getAttribute(VALUE_ATT);
     
    222234    return val;
    223235    }
     236   
    224237    /** extracts the text out of a node */
    225238    public static String getNodeText(Element param) {
     
    289302    }
    290303
     304    /** copies the metadata out of teh metadataList of 'from' into
     305     * the metadataList of 'to' */
    291306    public static boolean mergeMetadataLists(Node to, Node from) {
    292307    Node to_meta = getChildByTagName(to, METADATA_ELEM+LIST_MODIFIER);
     
    428443        p.setAttribute(DEFAULT_ATT, default_value);
    429444    }
    430     if (type.startsWith(PARAM_TYPE_ENUM) && options!=null) {
     445    if (type.startsWith(PARAM_TYPE_ENUM_START) && options!=null) {
    431446        for (int i=0; i<options.length; i++) {
    432447        Element e = owner.createElement(PARAM_OPTION_ELEM);
     
    460475    return param;
    461476    }
    462 
     477    /*
     478    public static Element createClassifierDisplay(Document owner, String name,
     479                          String name_text) {
     480    Element classifier = owner.createElement(CLASSIFIER_ELEM);
     481    classifier.setAttribute(NAME_ATT, name);
     482    classifier.appendChild(createTextElement(owner, DISPLAY_NAME_ELEM, name_text));
     483   
     484    return classifier;
     485    }
     486
     487    *
    463488    /** returns the element parent/node_name[@attribute_name='attribute_value']
    464489     */
     
    479504    }
    480505
     506
     507    /** Returns the appropriate language element from a display elem,
     508     display is the containing element, name is the name of the element to
     509     look for, lang is the preferred language, lang_default is the fall back
     510     lang if neither lang is found, will return the first one it finds*/
     511    public static String getDisplayText(Element display, String name,
     512                       String lang, String lang_default) {
     513    Element item = getNamedElement(display, name, GSXML.LANG_ATT, lang);
     514    if (item==null) {
     515        item = getNamedElement(display, name, GSXML.LANG_ATT, lang_default);
     516    }
     517    if (item ==null) {
     518        item = (Element)getChildByTagName(display, name); // just get the first one
     519    }
     520    if (item==null) {
     521        return ""; // should we return an empty string? or null?
     522    }
     523    return getNodeText(item);
     524
     525    }
    481526    // replaces < > " ' & in the original with their entities
    482527    public static String xmlSafe(String original) {
Note: See TracChangeset for help on using the changeset viewer.