Autogenerating BibTeX citations from ISBN

Looks like it can be done via WorldCat‘s xisbn API.

My approach is something like this:
foo:~ $ curl ',ed,title,author,publisher,city'

which returns an XML block like the following:

<?xml version="1.0" encoding="UTF-8"?>
<rsp xmlns="" stat="ok">
      <isbn   year="1986" ed="11th printing." title="Evolution and the theory of games"  author="John Maynard Smith."  publisher="Cambridge Univ. Press"  city="Cambridge [u.a.]"   >0521288843</isbn>

A little XSLT, such as that below:


    1 <?xml version="1.0"?>
    2 <xsl:stylesheet xmlns:xsl="" xmlns:wc="" version="1.0">
    3     <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
    4     <xsl:template match="wc:isbn">
    5         <code>
    6     @BOOK{CiteKeyGoesHere,
    7         AUTHOR = "<xsl:value-of select="@author"/>",
    8         TITLE = "<xsl:value-of select="@title"/>",
    9         PUBLISHER = "<xsl:value-of select="@publisher"/>",
   10         ADDRESS = "<xsl:value-of select="@city"/>",
   11         YEAR ="<xsl:value-of select="@year"/>"}
   12 </code>
   13     </xsl:template>
   14 </xsl:stylesheet>

…emits the following:

AUTHOR = "John Maynard Smith.",
TITLE = "Evolution and the theory of games",
PUBLISHER = "Cambridge Univ. Press",
ADDRESS = "Cambridge [u.a.]",
YEAR ="1986"}

The user will need to supply her own citation key, but many bibliography management tools (such as BibDesk) will do this, or you can use the bibtexformat perl script to insert them for you.

Here’s the whole deal in action. Creating a shell script which takes the ISBN as a parameter and plugs it into something like the following is left as an exercise for the reader.
$ curl -s ',ed,title,author,publisher,city' | xsltproc ~/Dev/book2bib.xsl -

AUTHOR = “John Maynard Smith.”,
TITLE = “Evolution and the theory of games”,
PUBLISHER = “Cambridge Univ. Press”,
ADDRESS = “Cambridge [u.a.]”,
YEAR =”1986″}

This entry was posted in Books, Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s