Access Keys:
Skip to content (Access Key - 0)
My Area (Access Key - 2)

Toggle Sidebar
Your Rating: Results: PatheticBadOKGoodOutstanding! 39 rates
elympics elympics Delete
oclc oclc Delete
webservice webservice Delete
actionbox actionbox Delete
webvoyage webvoyage Delete
tomcat tomcat Delete
voyager voyager Delete
intermediate intermediate Delete
apa apa Delete
citation citation Delete
mla mla Delete
chicago chicago Delete
turabian turabian Delete
harvard harvard Delete
sfx sfx Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

WebVoyage Tomcat - OCLC Citation in ActionBox for item

Tags: , , , , , , , , , , , , , ,
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.


'Fairly stable' - could be integrated with other products too (see "Other possibilities").

Programming language


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



Page attachments can be seen below.

Working examples

Using the following Ex Libris open interfaces currently used in TomCat WebVoyage


31 March 2010

Fixed an error in local_worldCatInfo.xsl so ISSNs are included in the URL sent to the oclccitation.cgi script, changing:


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:



- 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

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


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:

/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:
  1. the first addition in the same place in your file
  2. 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 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!


Let me know if you have any problems.

Page Attachments

File NameCommentSizeNumber of Downloads
local_worldCatInfo.xslXSL to embed the formatted citation (as an iframe).4 kB240
oclccitation.cgiPerl script to retrieve formatted citations15 kB491
editoclccitation.cgiPerl script to edit cached OCLC citations10 kB298
displayFacets.xslReference Ex Libris code to show additions to embed the formatted citation.4 kB238

Added by Tom Pasley on Mar 24, 2010 05:31, last edited by Tom Pasley on Apr 01, 2010 04:06

Adaptavist Theme Builder Powered by Atlassian Confluence