X hits on this document

366 views

0 shares

1 downloads

0 comments

125 / 142

Harvesting metadata with OAI-PMH

xsi:schemaLocation="http://purl http://www.openarchives.org/OAI

<creator>Twain, Mark</creator> <title>Tom Sawyer, Detective</t <date>1903</date> <identifier>http://www.infomoti <rights>This document is in the <language>en-US</language> <type>text</type> <format>text/plain</format> <relation>http://www.infomotion <relation>http://www.infomotion <relation>http://www.infomotion <relation>http://www.infomotion <contributor>Morgan, Eric Lease <contributor>Infomotions, Inc.<

.org/dc/elements/1.1/ /dc.xsd">

itle>

ons.com/etexts/literature/american/1900-/tw public domain.</rights>

  • s.

    com/alex/</relation>

  • s.

    com/alex/cgi-bin/concordance.pl?cmd=selec

  • s.

    com/alex/cgi-bin/configure-ebook.pl?handl

  • s.

    com/alex/cgi-bin/pdf.pl?handle=twain-tom-

</contributor> /contributor>

</dc> </metadata> </record> </GetRecord>

An Example

In an afternoon I created the very beginnings of an OAI data provider application using PHP. The source code to this application is available at http://www.infomotions.com/alex/oai/alex-oai-1.0.tar.gz. Below is a snippet of code implementing the ListIdentifiers verb. When this verb is trapped ListIdentifiers.php queries the system's underlying (MySQL) database for a list of keys and outputs the list as per the defined protocol:

<?php

  • #

    begin the response

echo '<ListIdentifiers xmlns="http://www.openarchives.org/OAI/1.0/OAI_ListIdentifiers" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/1.0/OAI_ListIdentifiers http://www.openarchives.org/OAI/1.0/OAI_ListIdentifiers.xsd">'; echo '<responseDate>'. RESPONSEDATE . '</responseDate>'; echo '<requestURL>' . REQUESTURL . '</requestURL>';

  • #

    create an sql query and execute it

$sql = "SELECT filename

FROM titles WHERE filename like 'twain%' ORDER BY filename"; $rows = mysql_db_query (DATABASE, $sql); checkResults();

  • #

    process each found record

while ($r = mysql fetch array($rows))

{

_

_

  • #

    display it

117

Document info
Document views366
Page views372
Page last viewedFri Dec 02 21:00:55 UTC 2016
Pages142
Paragraphs3126
Words34660

Comments