The project is no longer supported by this repository. The newest version is supported by National Documentation Center and you can find it here
OAI-PMH Objective-C harvester is an Objective C library/wrapper over the OAI-PMH protocol. The Open Archives Initiative Protocol for Metadata Harvesting (OAI-PMH) is a low-barrier mechanism for repository interoperability. Data Providers are repositories that expose structured metadata via OAI-PMH. Service Providers or metadata harvesters (like this one) then make OAI-PMH service requests to harvest that metadata. OAI-PMH is a set of six verbs or services that are invoked within HTTP.
-
Clone this project on your machine using the following command:
git clone https://github.com/kstamatis/OAI-PMH-Harvester-for-ObjC.git --recursive
-
Copy & Paste the folder OAIHarvester in your project, drag the folder in your XCode project as usual
-
In your projects precompiled header file (.pch extension) add the following lines
#import "TouchXML.h" #define BASE_NAMESPACE @"http://www.openarchives.org/OAI/2.0/"
-
Enable libxml2 library
- In XCode, within Build Settings, search for Header search paths setting and add
/usr/include/libxml2
value to it - In the same place, search for Other linker flags setting and add
-lxml2
value
- You are ready to use the library
Instantiate a new harvester
OAIHarvester *harvester = [[OAIHarvester alloc] initWithBaseURL:@"BASE URL OF YOUR OAI HERE"];
Identify instance is ready for you:<br>
NSLog(@"repo name = %@", harvester.identify.repositoryName);
NSLog(@"baseURL = %@", harvester.identify.baseURL);
NSLog(@"granularity = %@", harvester.identify.granularity);
for (NSString *email in harvester.identify.adminEmails){
NSLog(@"admin email = %@", email);
}
for (NSString *compression in harvester.identify.compressions){
NSLog(@"compression = %@", compression);
}
Metadata formats are also ready for you:
for (MetadataFormat *format in harvester.metadataFormats){
NSLog(@"%@: %@", format.prefix, format.namespce);
}
Sets are also ready for you:
for (Set *set in harvester.sets){
NSLog(@"%@: %@", set.fullSpec, set.name);
}
Define metadata prefix and set for your harvester (the latter is optional):
harvester.metadataPrefix = @"oai_dc";
harvester.setSpec = ((Set *)[harvester.sets objectAtIndex:0]).fullSpec;
List records (1st way - using resumption tokens):
NSArray *records = [harvester listRecordsWithResumptionToken:nil error:&error];
if (error){
NSLog(@"error = %@", [error localizedDescription]);
}
else {
if ([harvester hasNextRecords]){
NSArray *records2 = [harvester getNextRecordsWithError:&error];
Record *record = [records2 objectAtIndex:0];
NSLog(@"identifier = %@", record.recordHeader.identifier);
NSLog(@"status = %i", record.recordHeader.status);
NSLog(@"datestamp = %@", record.recordHeader.datestamp);
for (NSString *set in record.recordHeader.setSpecs){
NSLog(@"set = %@", set);
}
NSLog(@"namespace: %@", record.recordMetadata.namespce);
NSLog(@"schemaLoacation: %@", record.recordMetadata.schemaLocation);
for (MetadataElement *metadata in record.recordMetadata.metadataElements){
NSLog(@"%@: %@", metadata.name, metadata.value);
}
}
}
List records (2nd way - get all items at once):
NSArray *records = [harvester listAllRecords error:&error];
A fully detailed example can be found here. It is an open-source iOS example of how to use this library in a real OAI-PMH enabled repository, the one of Serres Public Library.
- No validation of the incoming xml
- No support for resumption tokens in the following verbs: ListSets
- No support for date selective harvesting for the verbs: ListIdentifiers and ListRecords
- No support for the "description" element in Identify verb
- No support for the "about" element in ListRecords verb
The only dependency of this project is the TouchXML library that can be found here.
Kostas Stamatis
National Documentation Center / NHRF
OAI-PMH ObjC Harvester by Konstantinos Stamatis is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.