-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestUpdateDC.php
78 lines (62 loc) · 2.05 KB
/
testUpdateDC.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env drush
#<?php
# include all php files necessary for Tuque
foreach ( glob("/var/www/drupal/htdocs/sites/all/libraries/tuque/*.php") as $filename) {
require_once($filename);
}
// $url = 'localhost:8080/fedora';
// $username = 'fedoraAdmin';
// $password = 'fedoraAdmin';
// # set up connection and repository variables
// $connection = new RepositoryConnection($url, $username, $password);
// $api = new FedoraApi($connection);
// $repository = new FedoraRepository($api, new SimpleCache());
# what is the pid you want?
$pid = 'islandora:3';
# try to fetch PID from repo
try {
$object = $repository->getObject($pid);
}
catch (Exception $e) {
drush_print('****************ERROR***************');
drush_print('***Could not get object from repo***');
exit;
}
$modsDS = $object['MODS'];
//$modsSimpleXML = simplexml_load_string($modsDC);
/*
echo $modsDS->content;
$modsXML = simplexml_load_string($modsDS->content);
$modsXML->name->namePart = 'Steve Buschemi';
$modsDS->setContentFromString($modsXML->asXML());
$object->ingestDatastream($modsDS);
echo $object['MODS']->content;
*/
/**
* 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.
*/
//function xml_form_builder_update_dc_datastream(AbstractObject $object, $transform, DOMDocument $document) {
$document = new DOMDocument();
$modsDatastream = $object['MODS'];
$document->loadXML($modsDatastream->content);
$transform = 'mods_to_dc.xsl';
xml_form_builder_update_dc_datastream($object, $transform, $document);
/*
$transform_path = 'mods_to_dc.xsl';
$source_document = new DOMDocument;
$source_document->load
simple_xml_load_string($object['MODS']->getContent())->asXML();
$xsl = new DOMDocument();
$xsl->load($transform_path);
$xslt = new XSLTProcessor();
$xslt->importStyleSheet($xsl);
$document = $xslt->transformToDoc($source_document);
echo $document->saveXML;
*/