Changeset 3600
- Timestamp:
- 2002-12-02T09:51:44+13:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java
r3573 r3600 32 32 public static final String CONFIGURE_ELEM = "configure"; 33 33 public static final String STATUS_ELEM = "status"; 34 34 public static final String DEFAULT_ELEM = "default"; 35 35 // elems for the pages to be processed by xslt 36 36 public final static String PAGE_ELEM = "page"; … … 59 59 public static final String ADDRESS_ATT = "address"; 60 60 public static final String PARAM_SHORTNAME_ATT = "shortname"; 61 public static final String PARAM_IGNORE_POS_ATT = "ignore"; 61 62 62 63 // parameter types … … 67 68 public static final String PARAM_TYPE_ENUM_MULTI = "enum_multi"; 68 69 public static final String PARAM_TYPE_STRING = "string"; 69 70 public static final String PARAM_TYPE_MULTI = "multi"; 70 71 71 72 // stuff for text strings … … 165 166 return param_map; 166 167 } 168 /** takes a paramList element, and gets a HashMap of name-value pairs */ 169 public static HashMap extractAllParams(Element xml) { 170 171 if (!xml.getNodeName().equals(PARAM_ELEM+LIST_MODIFIER)) { 172 System.err.println("GSXML:paramList element should have been passed to extractParams, instead it was "+xml.getNodeName()); 173 return null; 174 } 175 NodeList params = xml.getElementsByTagName(PARAM_ELEM); 176 HashMap param_map = new HashMap(); 177 for (int i=0; i<params.getLength(); i++) { 178 Element param = (Element)params.item(i); 179 String name=param.getAttribute(NAME_ATT); 180 String value=param.getAttribute(VALUE_ATT); 181 if (value.equals("")) { // the value is in the content of the param 182 value=getNodeText(param); 183 } 184 param_map.put(name, value); 185 186 } 187 return param_map; 188 } 167 189 168 190 public static String getValue(Element e) { … … 414 436 return null; 415 437 } 438 439 // replaces < > " ' & in the original with their entities 440 public static String xmlSafe(String original) { 441 442 StringBuffer filtered = new StringBuffer(original.length()); 443 char c; 444 for (int i=0; i<original.length(); i++) { 445 c = original.charAt(i); 446 if (c == '>') { 447 filtered.append(">"); 448 } else if (c == '<') { 449 filtered.append("<"); 450 } else if (c == '"') { 451 filtered.append("""); 452 } else if (c == '&') { 453 filtered.append("&"); 454 } else if (c == '\'') { 455 filtered.append("'"); 456 } else { 457 filtered.append(c); 458 } 459 } 460 return filtered.toString(); 461 } 416 462 }
Note:
See TracChangeset
for help on using the changeset viewer.