Changeset 23627 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Timestamp:
- 2011-01-24T13:17:24+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java
r23489 r23627 414 414 } 415 415 416 /** copies the metadata out of t ehmetadataList of 'from' into416 /** copies the metadata out of the metadataList of 'from' into 417 417 * the metadataList of 'to' */ 418 418 public static boolean mergeMetadataLists(Node to, Node from) { 419 Node to_meta = getChildByTagName(to, METADATA_ELEM+LIST_MODIFIER);420 419 Node from_meta = getChildByTagName(from, METADATA_ELEM+LIST_MODIFIER); 421 422 420 if (from_meta == null) { // nothing to copy 423 421 return true; 424 422 } 423 return mergeMetadataFromList(to, from_meta); 424 } 425 426 427 /** copies the metadata out of the meta_list metadataList into 428 * the metadataList of 'to' */ 429 public static boolean mergeMetadataFromList(Node to, Node meta_list) { 430 if (meta_list == null) return false; 431 Node to_meta = getChildByTagName(to, METADATA_ELEM+LIST_MODIFIER); 425 432 Document to_owner = to.getOwnerDocument(); 426 Node new_from = to_owner.importNode(from_meta, true); 427 428 if (to_meta == null) { // just copy the whole list 429 to.appendChild(new_from); 433 if (to_meta == null) { 434 to.appendChild(to_owner.importNode(meta_list, true)); 430 435 return true; 431 436 } 432 433 // copy individual elements 434 Node child = new_from.getFirstChild(); 435 while ( child != null) { 436 to_meta.appendChild(child); 437 child = child.getNextSibling(); 437 // copy individual metadata elements 438 NodeList meta_items = ((Element)meta_list).getElementsByTagName(METADATA_ELEM); 439 for (int i=0; i<meta_items.getLength(); i++) { 440 to_meta.appendChild(to_owner.importNode(meta_items.item(i),true)); 438 441 } 439 442 return true;
Note:
See TracChangeset
for help on using the changeset viewer.