OpenDOAR Tools: Application Programmers' Interface (API)
Download
Report
Transcript OpenDOAR Tools: Application Programmers' Interface (API)
Application
Programmers’
Interface
Digital Repositories: Dealing
with the Digital Deluge,
5-6June 2007, Manchester
Peter Millington
SHERPA Technical Development Officer
University of Nottingham, England
FOR DUMMIES® is a registered trademark of Wiley Publishing, Inc.
Application Programmers’ Interface (API)
• Using your Browser
• Loading OpenDOAR data into Microsoft Excel
– Simple tables – min & basic options – single-row records
– Complex – all other options – multi-row records
• Programmatically processing data
– e.g. PHP, PERL, etc
• Rendering data using XSL stylesheets
• Adding your own corporate style
API Browser Output
• Query specified in the address bar
– http://www.opendoar.org/api.php?co=gb&show=basic,index
– Searching for UK repositories (?co=gb)
– Output required:
• Popular fields (&show=basic) – for number of items held
• Index fields (&show=index) – for repository type
• Sorted by repository name (default)
• Raw XML Output
API & Excel: min and basic options
1. Specify query in File Open File Name
2. Select: Open XML As a List
3. For easier processing, copy to a new worksheet:
– Select All Copy Paste Special Values
4. Tidy up
– Delete unwanted columns - notably columns A to C
– View Zoom 75%
– Highlight header row & Window Freeze Panes below
– Adjust column widths to taste
5. Change rNumOfItems from strings to numbers
– Use formula =IF(ISBLANK(X2),"",INT(X2))
API & Excel: Other &show options
•
Approach similar to simple min & basic options
•
But returns multiple rows per repository
– Due to multiple subjects, languages, policies, etc.
•
Therefore may need to de-duplicate – e.g.
1. Add a temporary column next to rID or rName
2. Add formula such as =IF(B2=B1,">>>","")
3. Fill down column – duplicate rows are now tagged >>>
4. Select column & Copy Paste Special Values
5. Select All and sort on the temporary column
6. Delete all the rows tagged >>>
7. Delete the temporary column
OpenDOAR API – PHP Processing
• Check API query in web browser
– Note the order of required fields in each record
• rName
• rNumOfHits
• repositoryType
• Use PHP to loop through the output XML File
– Identify required XML field tags
– Extract data into variables
– Display data using HTML
• Add your own web style using HTML, CSS, etc.
Adding local style with HTML, CSS, etc
OpenDOAR API – Using XSL
• Check API query in web browser
• PHP (or PERL) program inserts link to XSL file
• XSL style sheet
– Adds HTML headers and footers
– May include local CSS styles and code
– Renders the required XML fields
• Advanced XSL
– Listing under headings
– Adding counts & calculations
– Etc.
Basic PHP wrapper
Simple XSL
Adds HTML headers & footers
Renders required XML fields
Recursive XSL
Lists repositories under country headings
Live Examples & Further Info
• Live Examples
– Browser output – Raw XML
• http://www.opendoar.org/api.php?co=gb&show=basic%2Cindex
– PHP-processed API output
• http://www.opendoar.org/documents/JISC200706demo1.php
– JISC-customised PHP-processed API output
• http://www.opendoar.org/documents/JISC200706demo2.php
– Simple XSL rendition of API output
• http://www.opendoar.org/documents/JISC200706demo3.php
– Recursive XSL rendition of API output
• http://www.opendoar.org/documents/JISC200706demo4.php
• Documentation for the OpenDOAR API
– http://www.opendoar.org/tools/api.html