Changeset 3850 for trunk/gsdl3
- Timestamp:
- 2003-03-11T16:53:23+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java
r3818 r3850 35 35 public static final String ERROR_ELEM = "error"; 36 36 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?? 38 39 public static final String TERM_ELEM = "term"; 39 40 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"; 40 48 // elems for the pages to be processed by xslt 41 49 public final static String PAGE_ELEM = "page"; … … 66 74 public static final String PARAM_SHORTNAME_ATT = "shortname"; 67 75 public static final String PARAM_IGNORE_POS_ATT = "ignore"; 68 76 public static final String CLASSIFIER_CONTENT_ATT = "content"; 69 77 public static final String DOC_NODE_ELEM = "documentNode"; 70 78 public static final String DOC_NODE_ID_ATT = "documentID"; … … 79 87 public static final String PARAM_TYPE_INTEGER = "integer"; 80 88 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"; 82 90 public static final String PARAM_TYPE_ENUM_SINGLE = "enum_single"; 83 91 public static final String PARAM_TYPE_ENUM_MULTI = "enum_multi"; … … 119 127 120 128 // 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 122 131 public static String [] getDocumentNameList(Element content) { 123 132 … … 147 156 } 148 157 158 // same as above function 149 159 /** extracts metadata names out of an element */ 150 160 public static String [] getMetaNameList(Element content) { … … 170 180 } 171 181 182 // combine the next two?? 172 183 /** takes a paramList element, and gets a HashMap of name-value pairs */ 173 184 public static HashMap extractParams(Element xml) { … … 213 224 } 214 225 226 /** gets the value att or the text content */ 215 227 public static String getValue(Element e) { 216 228 String val = e.getAttribute(VALUE_ATT); … … 222 234 return val; 223 235 } 236 224 237 /** extracts the text out of a node */ 225 238 public static String getNodeText(Element param) { … … 289 302 } 290 303 304 /** copies the metadata out of teh metadataList of 'from' into 305 * the metadataList of 'to' */ 291 306 public static boolean mergeMetadataLists(Node to, Node from) { 292 307 Node to_meta = getChildByTagName(to, METADATA_ELEM+LIST_MODIFIER); … … 428 443 p.setAttribute(DEFAULT_ATT, default_value); 429 444 } 430 if (type.startsWith(PARAM_TYPE_ENUM ) && options!=null) {445 if (type.startsWith(PARAM_TYPE_ENUM_START) && options!=null) { 431 446 for (int i=0; i<options.length; i++) { 432 447 Element e = owner.createElement(PARAM_OPTION_ELEM); … … 460 475 return param; 461 476 } 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 * 463 488 /** returns the element parent/node_name[@attribute_name='attribute_value'] 464 489 */ … … 479 504 } 480 505 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 } 481 526 // replaces < > " ' & in the original with their entities 482 527 public static String xmlSafe(String original) {
Note:
See TracChangeset
for help on using the changeset viewer.