Both sides previous revision
Previous revision
Next revision
|
Previous revision
|
repo:dcdate [2012/07/12 12:29] giancarlo |
repo:dcdate [2012/07/12 15:11] (current) giancarlo |
</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> |
| |
* b | * bmodify.xml example |
| |
<WRAP prewrap center> | <WRAP prewrap center> |
<code bash> | <code xml> |
| <?xml version="1.0" encoding="utf-8"?> |
| <fbm:batchModify xmlns:fbm="http://www.fedora.info/definitions/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fedora.info/definitions/ http://www.fedora-commons.org/definitions/1/0/api/batchModify-1.1.xsd"> |
| <fbm:modifyDatastream pid="fgramsci:TO024-00008-0056" dsID="DC" dsControlGroupType="X" logMessage="BatchModify - modifyDatastream"> |
| <fbm:xmlData> |
| <oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"> |
| <dc:title>Sisifo 8 - page 0056</dc:title> |
| <dc:creator>Istituto Gramsci piemontese</dc:creator> |
| <dc:subject>sviluppo; industria; welfare; lavoro; sociale; ricerca; innovazione; cultura, Piemonte, Torino</dc:subject> |
| <dc:description>idee, ricerche, programmi dell'Istituto Gramsci piemontese. Settembre 1986</dc:description> |
| <dc:publisher>Istituto Gramsci piemontese</dc:publisher> |
| <dc:type>Text</dc:type> |
| <dc:format/> |
| <dc:identifier>fgramsci:TO024-00008-0056</dc:identifier> |
| <dc:language>it</dc:language> |
| <dc:date>1986-09</dc:date> |
| </oai_dc:dc> |
| </fbm:xmlData> |
| </fbm:modifyDatastream> |
| </fbm:batchModify> |
</code> | </code> |
</WRAP> | </WRAP> |
| |
* c | * elenco.txt example |
| |
<WRAP prewrap center> | <WRAP prewrap center> |
<code bash> | <code> |
| openbess:TO095-00001,1984-12,4 |
| openbess:TO095-00002,1985-04,4 |
| openbess:TO095-00003,1985-06,4 |
| openbess:TO095-00004,1985-10,4 |
| openbess:TO095-00005,1986-02,4 |
| openbess:TO095-00006,1986,16 |
| openbess:TO095-00007,1987,12 |
| openbess:TO095-00008,1987,16 |
| openbess:TO095-00009,1987,16 |
| openbess:TO095-00010,1988,16 |
| openbess:TO095-00011,1988,16 |
| openbess:TO095-00012,1989,16 |
| openbess:TO095-00013,1989,16 |
| openbess:TO095-00014,1990,16 |
| openbess:TO095-00015,1991-05,24 |
| openbess:TO095-00016,1991-11,24 |
| openbess:TO095-00017,1992-04,24 |
</code> | </code> |
</WRAP> | </WRAP> |
| |
| * list books and number of page for collection (ITQL): |
| |
| <WRAP prewrap center> |
| <code> |
| select $member3 |
| count(select $pagine from <#ri> |
| where $pagine <fedora-rels-ext:isMemberOf> $member3 |
| ) |
| from <#ri> |
| where walk($object <fedora-rels-ext:isMemberOfCollection> <info:fedora/openbess:cognetti-C002> |
| and $member3 <fedora-rels-ext:isMemberOfCollection> $object) |
| and $member3 <fedora-model:hasModel> <info:fedora/islandora:bookCModel> |
| order by $member3 |
| </code> |
| </WRAP> |
| |