Archival Research: Custom Zotero Translators

FacebookTwitterGoogle+RedditLinkedIn

With more and more archival material being put up on the web, it is important to have a system for downloading and organizing that material for your research. I use zotero for all of my citation management because 1) it automatically pulls cites and files from the web and 2) it can store them to the cloud so they follow you wherever you go. For specialized electronic archives, however, there may not be a ready made zotero translator available. This was the case for the amazing Vietnam Virtual Archive at Texas Tech, so I rolled my own translator using the directions at the links provided below. I’ve made the full code available for anyone in need of a quick fix now, and I’ll put together something more substantial for the main zotero trunk when I get time.

http://niche-canada.org/member-projects/zotero-guide/chapter1.html
http://www.zotero.org/support/dev/how_to_write_a_zotero_translator_plusplus
http://www.zotero.org/support/dev/translators

//Zotero Translator for The Virtual Vietnam Archive at Texas Tech
//Rex W. Douglass
//6-29-2011

/*
Installation: Go to http://www.zotero.org/support/dev/translators/scaffold and install a firefox plugin called scaffold.
Run scaffold by going to the firefox button in the top left=>Scaffold
Make sure you are on the Metadata tab.
Enter the following information under each field
Label: VirtualVietnamArchive
Creator: Rex W. Douglass
Target: http://www.virtualarchive.vietnam.ttu.edu/starweb/virtual/vva/servlet.starweb
Then flip to the "Code" tab and paste the contents of this code.
Save by clicking the "Save" button, second from the left. Close scaffold and restart firefox.
*/

/*Use: Go to http://www.virtualarchive.vietnam.ttu.edu/starweb/virtual/vva/servlet.starweb?path=virtual/vva/virtual.web
Enter a search in the search terms box and hit search
For any of the results hit "more information"
Then to save the citation hit the zotero single page icon at the far right of the URL bar just before the bookmark star.
It will download the citation to your zotero library as well as all of the PDFs that are attached.
*/

function detectWeb(doc, url) {
    return "single";
}

function doWeb(doc, url) {

var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == "x" ) return namespace; else return null;
} : null;

    var newItem = new Zotero.Item("document");

    var TitlePath = '//div[2]/div[2]/div[2]/div[2]/div';
    var Title = doc.evaluate(TitlePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
    Zotero.debug(Title); 
    newItem.title = Title;

    var DatePath = '//div[2]/div[2]/div[2]/div[5]/div';
    var Date = doc.evaluate(DatePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
    Zotero.debug(Date); 
    newItem.date = Date;

    var LocationPath = '//div[2]/div[2]/div[2]/div[8]/div';
    var Location = doc.evaluate(LocationPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
    Zotero.debug(Location); 
    newItem.archiveLocation = Location;

    var CollectionPath = '//div[2]/div[2]/div[2]/div[6]/div/a';
    var Collection = doc.evaluate(CollectionPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
    Zotero.debug(Collection); 
    newItem.archiveLocation = Collection;

    var ItemNumPath = '//div[2]/div[2]/div[2]/div[1]/span[1]';
    var RecordNumPath = '//div[2]/div[2]/div[2]/div[1]/span[2]';

    var ItemNum = doc.evaluate(ItemNumPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
    var RecordNum = doc.evaluate(RecordNumPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
    newItem.extra = ItemNum + " " + RecordNum ;

    var PDFPath = '//div[2]/div[2]/div[2]/div[10]/div/div/a';
    var PDFOBJECT = doc.evaluate(PDFPath, doc, nsResolver, XPathResult.ANY_TYPE, null)
    var counter = doc.evaluate('count (' + PDFPath + ')', doc, nsResolver, XPathResult.ANY_TYPE, null);
    Zotero.debug(counter.numberValue);

    Zotero.debug(ItemNum);
    Zotero.debug(RecordNum);

    var headers;
    var count=1
    while (headers = PDFOBJECT.iterateNext()) {

    var PDFURL=headers.href

    newItem.attachments.push({
    title: Title + " (" + count + " of" + counter.numberValue + ")",
    mimeType:"application/pdf",
    url:PDFURL});

        count=count+1;
    }

    newItem.complete();

};
FacebookTwitterGoogle+RedditLinkedIn

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>