Archives: May 2009

Sending MARC(ish) data to Refworks

May 11, 2009 at 10:48 amCategory:Uncategorized

Refworks has some okish documentation about how to deal with its callback import procedure, but I thought I’d put down how I’m doing it for our vufind install (mirlyn2-beta.lib.umich.edu) in case other folks are interested.

The basic procedure is:

  • Send your user to a specific refworks URL along with a callback URL that can enumerate the record(s) you want to import in a supported form
  • Your user logs in (if need be) gets to her RefWorks page
  • RefWorks calls up your system and requests the record(s)
  • The import happens, and your user does whatever she want to do with them

Of course, there are lots of issues with doing this well (quick! Is this MARC record for a book? An edited book? Is it a journal, or a serial of some other sort? Who’s the actual author/editor?), but doing it at all isn’t so bad.

The URL to send them to

This is the “Export this record” URL on my system:

http://www.refworks.com.proxy.lib.umich.edu/express/expressimport.asp?
vendor=[your system]&
filter=MARC+Format&
database=All+MARC+Formats&
encoding=65001
&url=[your callback URL]
Note that the vendor variable should be a unique string (made up by your) for your system, not a larger entity (like the whole library or the institution).

The “MARC Format” filter we’re using is not a filter for real MARC. It’s a MARC-like delimited format (see an example from my catalog).

Basically, you have three types of lines (but really, look at the example, ’cause it’ll make everything a lot clearer):

LEADER

  LEADER [one space] [leader text]

Control Field

  [three-digit control tag] [four spaces] [data text]

Data Field

  [three-digit data tag] [one space] [ind1] [ind2] [one space] [value of subfield a] [other subfield constructs]

…where [other subfield constructs] look like

  [pipe characeter][subfield code][subfield value]

Notice that (a) there’s no leading ‘|a’ before the subfield a value, and (b) there are no spaces between the pipe, the subfield code, and the subfield value for the non-code-a subfields.

Some easy PHP code to produce such a format is as follows. Note that I’m sending it as text (because it’s not MARC) and UTF-8. If you’re got MARC-8, you’ll have to convert it before sending.

  1.       $m = $this->marcRecord;
  2.       header('Content-type: text/plain; charset=UTF-8');
  3.  
  4.       echo 'LEADER ', $m->getLeader(), "\n";
  5.      
  6.       foreach ($m->getFields() as $tag => $val) {
  7.         echo $tag;
  8.         if ($val instanceof File_MARC_Control_FIELD) {
  9.           echo '    ', $val->getData(), "\n";
  10.         } else {
  11.           echo ' ', $val->getIndicator(1),  $val->getIndicator(2), ' ';
  12.           $subs = array();
  13.           foreach ($val->getSubFields() as $code=>$subdata) {
  14.             $line = '';
  15.             if ($code != 'a') {
  16.               $line = '|' . $code;
  17.             }
  18.             $subs[] = $line . $subdata->getData();
  19.           }
  20.           echo implode(' ', $subs), "\n";
  21.         }        
  22.       }

3 Responses to “Sending MARC(ish) data to Refworks”

  1. Dan Scott says:

    Bill – thanks so much for this! A working example makes all the difference for other people following in your wake. (Once the waves finish washing over my head, I hope to implement RefWorks export in Evergreen…)

  2. [...] Sending citations to RefWorks can be done with a callback. Essentially, you add a link to RefWorks’ import function page and send it your credentials, as well as a callback URL that RefWorks uses to grab the record from your ILS…in a RefWorks-supported format. The problem is that RefWorks doesn’t accept MODS, MARC, or even MARCXML. They say they accept MARC, but it’s actually what I call “MARC text” (it is described very well by Bill Dueber). [...]

  3. Ali says:

    Hi Bill,

    Good stuff. I will see if I can do similar for YorkU Vufind Instance.

    Cheers,

    Ali

Leave a Reply