【发布时间】:2015-12-18 21:59:39
【问题描述】:
是否可以使用 DSpace 从其他存储库中收集单个项目?也许从命令行? 据我所知,使用 XMLUI 只能收获完整的社区或完整的集合。但后来我得到了太多我不需要的东西。
【问题讨论】:
标签: dspace
是否可以使用 DSpace 从其他存储库中收集单个项目?也许从命令行? 据我所知,使用 XMLUI 只能收获完整的社区或完整的集合。但后来我得到了太多我不需要的东西。
【问题讨论】:
标签: dspace
OAI-PMH 标准提供了 GetRecord 方法。
https://knb.ecoinformatics.org/knb/docs/oaipmh.html
如果您浏览包含您感兴趣的项目的集合,您应该能够找到该项目的标识符。您可以将该标识符用作 GetRecord 的参数。
这将允许您提取项目元数据。为了将项目放入 DSpace,我想您需要将项目打包以提取到存储库中。
【讨论】:
正如 Terry 所写,您可以使用 GetRecord 请求从存储库中获取单个项目/文档。 如果 zip 的内容具有特定格式,则可以使用 DSpace 菜单项“批量导入 (ZIP)”项导入。
以下 PHP 代码从 GetRecord 创建的 XML 中提取元数据。 在下一步中,此元数据以 DSpace 可以理解的 XML 格式打包。 此 XML 将作为文件 (dublin_core.xml) 添加到创建的 ZIP 中,同时还有一个包含句柄的小文件 (handle)。 最后将 ZIP 写入服务器。
顺便说一句,也可以从命令行导入 zip 文件,正如 Terry 在他的第一个答案中提到的那样。
<?php
// handle and harvest-string
$handle = "1874/1506";
$harvest = "http://dspace.library.uu.nl/oai/request?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai:dspace.library.uu.nl:" . $handle;
// get XML from source repository
$sxe = simplexml_load_file($harvest, "SimpleXMLElement");
// add namespace schema-urls
$sxe->registerXPathNamespace('oai_dc', 'http://www.openarchives.org/OAI/2.0/oai_dc/');
$sxe->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
// get Dublin Core (dc) elements from the XML
foreach($sxe->xpath("//oai_dc:dc") as $entry) {
$child = $entry->children('dc', true);
}
// add dc-elements (names and values) to array
foreach($child as $elementName => $elementValue) {$elements[$elementName][] = $elementValue;}
// create zip-object and -file
$zip = new ZipArchive();
$zip->open("doc/importZip.zip", ZipArchive::CREATE);
// create a directory in the zip-object
$zip->addEmptyDir("item");
// create Dublin Core XML object
$oXML = new DOMDocument();
$oXML->encoding = "UTF-8";
$oXML->formatOutput = true;
$oXML->xmlStandalone = false;
$oRoot = $oXML->createElement('dublin_core');
$oRoot->setAttribute('schema', 'dc');
$oXML->appendChild($oRoot);
// add elements and their values to XML object
foreach($elements as $elementName => $elementValues) {
foreach($elementValues as $elementValue) {
$oDcValue = $oXML->createElement('dcvalue');
$oDcValue->setAttribute('element', $elementName);
$oText = $oXML->createTextNode($elementValue);
$oDcValue->appendChild($oText);
$oRoot->appendChild($oDcValue);
}
}
// save created XML to string
$dublinCoreXml = $oXML->saveXML();
// add XML-string as file to zip-object
$zip->addFromString("item/1/dublin_core.xml", $dublinCoreXml);
// add handle as file to zip-object
$zip->addFromString("item/1/handle", $handle);
$zip->close();
?>
【讨论】:
dim 作为元数据前缀,我应该在您的示例代码中进行哪些更改?提前致谢。
如果您希望通过命令行提取单个项目,请考虑打包程序命令。
https://wiki.duraspace.org/display/DSDOC5x/Importing+and+Exporting+Content+via+Packages
【讨论】: