- Timestamp:
- 2005-05-16T11:02:50+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java
r9261 r9874 99 99 public static final String PARAM_IGNORE_POS_ATT = "ignore"; 100 100 public static final String CLASSIFIER_CONTENT_ATT = "content"; 101 101 public static final String ERROR_TYPE_ATT = "type"; 102 102 103 // document stuff 103 104 public static final String DOC_TYPE_ATT = "docType"; … … 173 174 public static final String COMM_TYPE_SOAP_JAVA = "soap"; 174 175 176 // error types 177 public static final String ERROR_TYPE_SYNTAX = "syntax"; 178 public static final String ERROR_TYPE_SYSTEM = "system"; 179 public static final String ERROR_TYPE_INVALID_ID = "invalid_id"; 180 public static final String ERROR_TYPE_OTHER = "other"; 181 175 182 // some system wide param names 176 183 public static final String SUBSET_PARAM = "subset"; … … 279 286 } 280 287 288 /** add an error message, unknown error type */ 289 public static boolean addError(Document owner, Element doc, String text) { 290 return addError(owner, doc, text, ERROR_TYPE_OTHER); 291 } 281 292 /** add an error message */ 282 public static boolean addError(Document owner, Element doc, String text) { 293 public static boolean addError(Document owner, Element doc, String text, 294 String error_type) { 283 295 284 296 Element content = owner.createElement(ERROR_ELEM); 297 content.setAttribute(ERROR_TYPE_ATT, error_type); 285 298 Text t = owner.createTextNode(text); 286 299 content.appendChild(t); … … 291 304 /** add an error message */ 292 305 public static boolean addError(Document owner, Element doc, Throwable error) { 293 error.printStackTrace(); 294 return addError(owner, doc, error.toString()); 306 return addError(owner, doc, error, ERROR_TYPE_OTHER); 307 } 308 309 /** add an error message */ 310 public static boolean addError(Document owner, Element doc, 311 Throwable error, String error_type) { 312 error.printStackTrace(); 313 return addError(owner, doc, error.toString(), error_type); 295 314 } 296 315 … … 402 421 } 403 422 423 public static NodeList getChildrenByTagName(Node n, String name) { 424 MyNodeList node_list = new MyNodeList(); 425 Node child = n.getFirstChild(); 426 while (child!=null) { 427 if (child.getNodeName().equals(name)) { 428 node_list.addNode(child); 429 } 430 child = child.getNextSibling(); 431 } 432 return node_list; 433 } 434 404 435 405 436 /** Duplicates an element, but gives it a new name */ … … 407 438 String element_name, boolean with_attributes) 408 439 { 409 Element duplicate = owner.createElement(element_name); 410 440 return duplicateWithNewNameNS(owner, element, element_name, null, with_attributes); 441 } 442 443 /** Duplicates an element, but gives it a new name */ 444 public static Element duplicateWithNewNameNS(Document owner, 445 Element element, 446 String element_name, 447 String namespace_uri, 448 boolean with_attributes) 449 { 450 Element duplicate; 451 if (namespace_uri == null) { 452 duplicate = owner.createElement(element_name); 453 } else { 454 duplicate = owner.createElementNS(namespace_uri, element_name); 455 } 411 456 // Copy element attributes 412 457 if (with_attributes) {
Note:
See TracChangeset
for help on using the changeset viewer.