Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application...

36
Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers’ Interface Digital Repositories: Dealing with the Digital Deluge, 5-6June 2007, Manchester FOR DUMMIES® is a registered trademark of Wiley Publishing, Inc.

Transcript of Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application...

Page 1: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

Peter Millington

SHERPA Technical Development Officer

University of Nottingham, England

Application Programmers’

InterfaceDigital Repositories: Dealing

with the Digital Deluge,5-6June 2007, Manchester

FOR DUMMIES® is a registered trademark of Wiley Publishing, Inc.

Page 2: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

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

Page 5: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

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

Page 7: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

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))

Page 14: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

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

Page 18: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

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.

Page 23: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

Adding local style with HTML, CSS, etc

Page 24: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

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.

Page 25: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

Basic PHP wrapper

Page 26: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

Simple XSL

Adds HTML headers & footers

Renders required XML fields

Page 31: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

Recursive XSL

Lists repositories under country headings

Page 36: Peter Millington SHERPA Technical Development Officer University of Nottingham, England Application Programmers Interface Digital Repositories: Dealing.

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