drush_print("\n\n**********####### ERROR #######*********"); drush_print("***Could not set {$objectPID} MODS datastream content or ingest into repo ****\n\n"); $skippedObjects[] = $objectPID; continue; } // drush_print("MODS record updated for object pid: $objectPID\n"); /*************MODS RECORD COMPLETE*****************/ try { /******************DUBLIN CORE ********************/ // drush_print("Re-generating Dublin Core"); // update the DC based on the MODS record $document = new DOMDocument(); $document->loadXML($modsDS->content); $transform = 'mods_to_dc.xsl'; // the magic call xml_form_builder_update_dc_datastream($object, $transform, $document); // drush_print("Dublin core regenerated"); /*************DUBLIN CORE COMPLETE*****************/ // keep track of how many objects we edited $objectsChanged++; } catch (Exception $e) { drush_print("\n\n**********####### ERROR #######*********"); drush_print("***Could not update {$objectPID} DC record ****\n\n"); $skippedObjects[] = $objectPID; continue; } } } drush_print("Main processing loop complete"); drush_print("{$objectsChanged} out of {$totalNumObjects} were updated"); if (!empty($skippedObjects)) {
// load file if (file_exists('/root/jpdcrecord.xml')) { $dcRecord = simplexml_load_file('/root/jpdcrecord.xml'); } else { echo "\n**********ERROR LOADING FILE********\n"; return; } $dcDOMDoc = new DOMDocument(); $dcDOMDoc->loadXML($dcRecord->asXML()); $dcXPath = new DOMXPath($dcDOMDoc); $dcXPath->registerNameSpace('dc', 'http://purl.org/dc/elements/1.1/'); $xml_out = $dcDOMDoc->saveXML($dcDOMDoc->documentElement); echo $xml_out . "\n\n"; foreach ($dcXPath->query('dc:contributor') as $node) { echo $node->nodeValue; } //xml_form_builder_transform_document($transform, $source_document) xml_form_builder_transform_document($transform, $dcDOMDoc); /** * Updates the DC datastream by applying the given transform. * * @param AbstractObject $object * The object whose DC will be updated. * @param string $transform * The transform to apply, as defined by the forms association. * @param DOMDocument $document * The document to transform. */ //xml_form_builder_update_dc_datastream(AbstractObject $object, $transform, DOMDocument $document); xml_form_builder_update_dc_datastream($object, $transform, $dcDOMDoc);