- Timestamp:
- 2016-07-28T12:53:59+12:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java
r30584 r30629 139 139 public static final String FROM_ATT = "from"; 140 140 public static final String LANG_ATT = "lang"; 141 public static final String KEY_ATT = "key"; 141 142 public static final String HREF_ATT = "href"; 142 143 public static final String TYPE_ATT = "type"; … … 1261 1262 return att_value; 1262 1263 } 1263 /**1264 * Returns the appropriate language element from a display elem, display is1265 * the containing element, name is the name of the element to look for, lang1266 * is the preferred language, lang_default is the fall back lang if neither1267 * lang is found, will return the first one it finds1268 */1269 public static String getDisplayText(Element display, String name, String lang, String lang_default)1270 {1271 1272 String def = null;1273 String first = null;1274 NodeList elems = display.getElementsByTagName(DISPLAY_TEXT_ELEM);1275 if (elems.getLength() == 0)1276 return "";1277 for (int i = 0; i < elems.getLength(); i++)1278 {1279 Element e = (Element) elems.item(i);1280 String n = e.getAttribute(NAME_ATT);1281 if (name.equals(n))1282 {1283 String l = e.getAttribute(LANG_ATT);1284 if (lang.equals(l))1285 {1286 return getNodeText(e);1287 }1288 else if (lang_default.equals(l))1289 {1290 def = getNodeText(e);1291 }1292 else if (first == null)1293 {1294 first = getNodeText(e);1295 }1296 }1297 else1298 {1299 continue;1300 }1301 }1302 1303 if (def != null)1304 {1305 return def;1306 }1307 if (first != null)1308 {1309 return first;1310 }1311 return "";1312 }1313 1264 1314 1265 // replaces < > " ' & in the original with their entities
Note:
See TracChangeset
for help on using the changeset viewer.