- Timestamp:
- 2012-09-26T12:44:23+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java
r26248 r26253 122 122 } 123 123 124 125 124 public static String replace(String orig, String match, String replacement) 126 125 { … … 169 168 } 170 169 171 172 170 public static String getInterfaceText(String interface_name, String lang, String key) 173 171 { … … 283 281 } 284 282 285 public static String getCollectionText(String collection, String site_name, String lang, String key) { 286 return getCollectionTextWithDOMMulti(collection, site_name, lang, key); 287 } 288 // xslt didn't like calling the function with Node varargs, so have this hack for now 289 public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1) { 290 return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1); 291 } 292 public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2) { 293 return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2); 294 } 295 public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2, Node n3) { 296 return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2, n3); 297 } 298 public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2, Node n3, Node n4) { 299 return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2, n3, n4); 300 } 301 public static String getCollectionTextWithDOMMulti(String collection, String site_name, String lang, String key, Node ... nodes) { 302 303 int num_nodes = nodes.length; 304 String [] args = null; 305 if (num_nodes != 0) { 306 args = new String[num_nodes]; 307 308 for (int i=0; i<num_nodes; i++) { 309 310 String node_str = XMLConverter.getString(nodes[i]); 311 args[i] = node_str; 312 } 313 } 314 CollectionClassLoader class_loader = new CollectionClassLoader(XSLTUtil.class.getClassLoader(), GSFile.siteHome(GlobalProperties.getGSDL3Home(), site_name), collection); 315 Dictionary dict = new Dictionary(collection, lang, class_loader); 316 String result = dict.get(key, args); 317 if (result != null) { 318 return result; 319 } 320 return "text:"+collection+":"+key; 321 322 } 323 283 public static String getCollectionText(String collection, String site_name, String lang, String key) 284 { 285 return getCollectionTextWithDOMMulti(collection, site_name, lang, key); 286 } 287 288 // xslt didn't like calling the function with Node varargs, so have this hack for now 289 public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1) 290 { 291 return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1); 292 } 293 294 public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2) 295 { 296 return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2); 297 } 298 299 public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2, Node n3) 300 { 301 return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2, n3); 302 } 303 304 public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2, Node n3, Node n4) 305 { 306 return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2, n3, n4); 307 } 308 309 public static String getCollectionTextWithDOMMulti(String collection, String site_name, String lang, String key, Node... nodes) 310 { 311 int num_nodes = nodes.length; 312 String[] args = null; 313 if (num_nodes != 0) 314 { 315 args = new String[num_nodes]; 316 317 for (int i = 0; i < num_nodes; i++) 318 { 319 320 String node_str = XMLConverter.getString(nodes[i]); 321 args[i] = node_str; 322 } 323 } 324 325 CollectionClassLoader class_loader = new CollectionClassLoader(XSLTUtil.class.getClassLoader(), GSFile.siteHome(GlobalProperties.getGSDL3Home(), site_name), collection); 326 Dictionary dict = new Dictionary(collection, lang, class_loader); 327 String result = dict.get(key, args); 328 if (result != null) 329 { 330 return result; 331 } 332 return "text:" + collection + ":" + key; 333 334 } 324 335 325 336 public static boolean isImage(String mimetype) … … 332 343 } 333 344 334 335 336 345 // formatting /preprocessing functions 346 // some require a language, so we'll have a language param for all 347 public static String toLower(String orig, String lang) 337 348 { 338 349 return orig.toLowerCase(); … … 344 355 } 345 356 346 357 public static String tidyWhitespace(String original, String lang) 347 358 { 348 359 … … 355 366 } 356 367 357 368 public static String stripWhitespace(String original, String lang) 358 369 { 359 370
Note:
See TracChangeset
for help on using the changeset viewer.