WebVoyage Tomcat - OCLC Citation in ActionBox for item
Tags: elympics
, oclc
, webservice
, actionbox
, webvoyage
, tomcat
, voyager
, intermediate
, apa
, citation
, mla
, chicago
, turabian
, harvard
, sfx
Last Updated: Apr 01, 2010 04:06
- Description
This facility is really popular with, (mainly), our first-year students, who are new to APA, and referencing in general.
It uses an OCLC webservice, (requires registration), to retrieve a formatted citation for a book, or journal. The citation can be in either APA, Chicago, Harvard, MLA or Turabian formats. The advantage of this script is that, if you don't have an OCLC number for the book or journal, (a required parameter of the webservice), you can use an ISBN or ISSN instead. If an ISSN or ISBN is provided, then the xISSN or xISBN API (also provided by OCLC) is used, so there will be a slight delay, but the citation is cached for later use.
- Author:
- Tom Pasley
- Institution:
- Universal College of Learning
- Year:
- 2010
License: BSD style
Short description: Use, modification and distribution of the code are permitted provided the copyright notice, list of conditions and disclaimer appear in all related material.
Link to terms: [Detailed license terms]
Skill required for using this code:
- Intermediate, provided Perl is installed on your webserver - requires telnet access to server to set permissions for script.
- State
- Programming language
- Software requirements
- Screen captures
- Author(s) email
- Download
- Working examples
- Using the following Ex Libris open interfaces
- Changes
- Release notes
- OCLC WorldCat API registration
- Installation instructions
- Optional extra install (-allows editing of cached citations)
- TO DO list
- Other possibilities...
- Known issues
- Comments
State
'Fairly stable' - could be integrated with other products too (see "Other possibilities").
Programming language
Perl
Software requirements
Requires your Perl to be installed and configured on a suitable webserver.
Uses a number of Perl modules:
- HTTP::Request
- Unicode::Normalize
- URI::Escape
- XML::Simple
- LWP::UserAgent
- which were part of our install, although your mileage may vary.
Screen captures
Example from "actionbox" in record:

Example "standalone" from the Perl script:

Author(s) email
t.pasley@(nospam)ucol.ac.nz
Download
Page attachments can be seen below.
Working examples
http://libcat.ucol.ac.nz/vwebv/holdingsInfo?bibId=17529&sk=sandbox
http://libcat.ucol.ac.nz/vwebv/oclccitation.cgi?isbn=0815110065&bibId=17529
Using the following Ex Libris open interfaces
...as currently used in TomCat WebVoyage
Changes
31 March 2010
Fixed an error in local_worldCatInfo.xsl so ISSNs are included in the URL sent to the oclccitation.cgi script, changing:
to
31 March 2010
I've made the oclccitation.cgi script slightly more secure, and made sure we didn't trust the input for the script more than we had to... I've added two subroutines to purify script inputs for numbers (bibID and oclcnum) and ISNs (ISBN and ISSN).
The cached path should be absolute (i.e. from the root directory of your server), to help make the script secure.
The error messages are also more explicit, to help provide the user with an idea of why there is no citation.
Also added code to catch response for "unknownId" in OCLC response.
Initial release
Ported from PHP, with significant modifications.
Release notes
Requires registration with the OCLC webservice, (details below), to provide a functional OCLC webservices key, which you must enter in the script:
replace:
DMuvU3v3GkxLdzoRoekucr6feeEAbaFW4kdMz5IAP1WZvI93EuTheQ20ZrgAvv5AJzmSnss8WnIzy
- with your valid OCLC webservices key (this one isn't valid).
OCLC WorldCat API registration
Qualifying OCLC Member libraries can sign up for a WorldCat Search API key at http://www.worldcat.org/affiliate/tools?atype=wcapi.
The WorldCat Basic API can be used, so if you're not an OCLC Member Library, you can still sign up for a WorldCat Basic Key at http://www.worldcat.org/wcpa/content/affiliate/default.jsp. Although the Basic service provides only 1,000 queries a day, that should be more than enough for most situations.
Installation instructions
There are three files to configure and install, in this order:
oclccitation.cgi
Configure these variables (takes 2 minutes or so - very easy):
- my $cache_path (must be read/writable by everyone)
- my $oclcwskey
- my $affiliateID
- my $citationTitle
- my $preCitationText
- my $postCitationText
- my $citation_style
Place in Perl cgi-bin directory on your configured Apache server, and make executable using
Make sure that the script works, by trying with some examples, with this link template:
http://path.to/script/oclccitation.cgi?isbn=isbn&bibId=bibIDofitem
/xsl/pageFacets/displayFacets.xsl (Ex Libris code reference supplied) - backup your own copy before making changes.
| see the attached copy for reference - the additions are annotated with: |
- the first addition in the same place in your file
- the second addition in a similar place (though you can move it up if you want to, while preserving the html structure).
xsl/local_worldCatInfo.xsl (supplied)
| Edit the XSL variable citationScript by replacing http://libcat.ucol.ac.nz/vwebv/oclccitation.cgi with the path to your own script |
Optional extra install (-allows editing of cached citations)
If you want, you can also install editoclccitation.cgi - provided you sort out where to put it (I've put it in our webadmin/cgi-bin directory). You can put it anywhere that you can provide protection using Apache config, using directives similar to those for webadmin.
Configure these variables (takes 2 minutes or so - very easy):
- my $cache_path
- my $affiliateID
- my $citationTitle
- my $preCitationText
- my $postCitationText
- my $css
Place in Perl cgi-bin directory on your configured Apache server, and make executable using
And then test that it works by using the page in question:

it should be straightforward from that point on, provided you know basic html - in this example, the publisher is different from that provided in the OCLC citation:
TO DO list
It seems to be okay with OCLC to cache, and edit the response.
Other possibilities...
| There's no reason why this facility couldn't be added to SFX or other systems (if it doesn't exist already) - this could be done quite simply by altering the code so that the response from the Perl script outputs the citation in a way which is amenable to the script(s) calling it. This could be done by editing the $bibId references to rely on just the ISBN, ISSN, or OCLC number, and adjusting the filename under which the citation would be cached.
If you're interested in these possibilities, then feel free to alter the code to suit your situation. Alternatively, you can contact me, and I can give some pointers about how this could be easily done. |
Known issues
editoclccitation.cgi :
- You may have trouble with permissions, if you haven't configured the directory properly. When editing citations, you can either do this via FTP, (as the voyager user), or by the cgi script I've provided. However, you can't edit a record that you've FTP'd using this script, as it will have different privileges!
Comments
Let me know if you have any problems.

