OCLC Developer Network

Finding the original edition using xISBN services

Another question that was asked at the OCLC Web Services Bootcamp at VALA was "Can I find the earliest edition with xID?" The answer is Yes The getEditions response from xISBN has fields for both edition and year published information. Edition information is sometimes missing so the best way to handle finding the earliest edition is to use the year field. There are a couple different ways one might do this. One could use an XSL to sort the nodes ascending by year and then pull out the ISBN or OCLC Number of the first one. Another possibility is to use the SimpleDOM library for PHP to sort the nodes and pull out the ISBN or OCLC Number from the first one. Below is a sample script PHP script which takes the XML output of xISBN sorts by year and then prints the Year and ISBN. I'm using the forementioned SimpleDOM PHP library.

<?php
include 'SimpleDOM.php';

$xisbn_request = 'http://xisbn.worldcat.org/webservices/xid/isbn/0596002815?method=getEditions&format=xml&fl=year,ed';

$xisbn_xml = simpledom_load_file($xisbn_request);
$xisbn_xml->registerXPathNamespace("xid", "http://worldcat.org/xid/isbn/");
header('Content-type: text/plain');
foreach ($xisbn_xml->sortedXpath('//xid:isbn' , '@year') as $edition) {
	echo "\n";
	echo 'Year: ' . $edition['year'] . "\n";
	echo 'ISBN: ' . $edition;
	echo "\n";	
}
?>

There are probably other ways to do this as well using the JSON format but I'm still learning JSON. If someone would like to post an example using JSON I'd appreciate it.

Follow the OCLC Developer Network:

The OCLC Developer Network supports the use of OCLC Web Services—a set of tools and APIs that expose data and services for WorldCat and our member libraries and partner institutions or companies. learn more »

© 2010 OCLC Domestic and international trademarks and/or service marks of OCLC Online Computer Library Center, Inc. and its affiliates


Powered by Drupal, an open source content management system