Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
repo:dcdate [2012/07/12 12:29]
giancarlo
repo:dcdate [2012/07/12 12:31]
giancarlo
Line 69: Line 69:
 </WRAP> </WRAP>
  
-  * a+  * modificaDCdate.php
  
 <WRAP prewrap center> <WRAP prewrap center>
-<code bash>+<code php> 
 +#!/usr/bin/php 
 +<?php 
 +if ($argc != 3 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) { 
 +?> 
 + 
 +This is a command line PHP script with two options. 
 + 
 +  Usage: 
 +  <?php 
 +    echo $argv[0]; ?> <option> 
 + 
 +  <option> can be some word you would like 
 +  to print out. With the --help, -help, -h, 
 +  or -? options, you can get this help. 
 + 
 +<?php 
 +    exit; 
 +} else { 
 +    $PID = $argv[1]; 
 +    $Nuovadata = $argv[2]; 
 +
 +$indoc = new DOMDocument(); 
 +$indoc->formatOutput = true; 
 +$indoc->preserveWhiteSpace = false; 
 +$indoc->load('http://fc1.to.cnr.it:8080/fedora/objects/' . $PID . '/datastreams/DC/content'); 
 +$innode = $indoc->getElementsByTagNameNS('http://www.openarchives.org/OAI/2.0/oai_dc/', 'dc')->item(0); 
 +$dcdate = $innode->getElementsByTagNameNS('http://purl.org/dc/elements/1.1/', 'date')->item(0); 
 +$olddcdate = $innode->removeChild($dcdate); 
 +print_r($dcdate->nodeValue . " <- " . $Nuovadata . "\n"); 
 +$newdate = $indoc->createElement('dc:date', $Nuovadata); 
 +$innode->appendChild($newdate); 
 +$dom = new DOMDocument('1.0', 'utf-8'); 
 +$dom->formatOutput = true; 
 +$dom->preserveWhiteSpace = false; 
 +$element = $dom->createElement('fbm:batchModify'); 
 +$element->setAttribute('xmlns:fbm', 'http://www.fedora.info/definitions/'); 
 +$element->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); 
 +$element->setAttribute('xsi:schemaLocation', 'http://www.fedora.info/definitions/ http://www.fedora-commons.org/definitions/1/0/api/batchModify-1.1.xsd'); 
 +$dom->appendChild($element); 
 +$element1 = $dom->createElement('fbm:modifyDatastream'); 
 +$element1->setAttribute('pid', $PID); 
 +$element1->setAttribute('dsID', 'DC'); 
 +$element1->setAttribute('dsControlGroupType', 'X'); 
 +$element1->setAttribute('logMessage', 'BatchModify - modifyDatastream'); 
 +$element->appendChild($element1); 
 +$element2 = $dom->createElement('fbm:xmlData'); 
 +$element1->appendChild($element2); 
 +$newnode = $dom->importNode($innode, true); 
 +$element2->appendChild($newnode); 
 +// print $dom->saveXML()."\n"; 
 +// print "======================"."\n"; 
 +print 'Wrote: ' . $dom->save("bmodify.xml") . ' bytes' . "\n"; 
 +?>
 </code> </code>
 </WRAP> </WRAP>
 
 
repo/dcdate.txt · Last modified: 2012/07/12 15:11 by giancarlo

Developers: CNR IRCrES IT Office and Library
Giancarlo Birello (giancarlo.birello _@_ ircres.cnr.it) and Anna Perin (anna.perin _@_ ircres.cnr.it)
DigiBess is licensed under: Creative Commons License
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Drupal Garland Theme for Dokuwiki