{ "translatorID":"99be9976-2ff9-40df-96e8-82edfa79d9f3", "translatorType":4, "label":"Defense Technical Information Center", "creator":"Matt Burton", "target":"http://oai\\.dtic\\.mil/oai/", "minVersion":"1.0.0b3.r1", "maxVersion":"", "priority":100, "inRepository":true, "lastUpdated":"2009-07-29 06:35:00" } function detectWeb(doc, url) { if(doc.title.indexOf("DTIC OAI Index for") != -1) { return "multiple"; } else if (url.indexOf("verb=getRecord") != -1){ return "report"; } } function doWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == 'x') return namespace; else return null; } : null; var newURIs = new Array(); if(detectWeb(doc,url) == "multiple"){ var links = doc.evaluate("//a/@href", doc, nsResolver, XPathResult.Abstract, null); var titles = doc.evaluate("//a/preceding::text()[1]", doc, nsResolver, XPathResult.Abstract, null); var items = new Object(); var link, title; while( link = links.iterateNext(), title = titles.iterateNext()){ items[link.textContent.replace(/&metadataPrefix=html/, "&metadataPrefix=oai_dc")] = title.textContent; } items = Zotero.selectItems(items); if(!items) { return true; } for (url in items) { newURIs.push(url); Zotero.debug(url); } } else { newURIs.push(url.replace(/&metadataPrefix=html/, "&metadataPrefix=oai_dc")) } // ripped the arXiv.org code, hence the funny var names. Zotero.Utilities.HTTP.doGet(newURIs, function(text) { var newItem = new Zotero.Item("report"); // remove header text = text.replace(/]*>/, "").replace(/<\?xml[^>]*\?>/, ""); // fix non-compliant XML tags (colons) text = text.replace(/]*>/, "").replace(/<\/OAI-PMH[^>]*>/, ""); text = "" + text + ""; var xml = new XML(text); var title; var citation = xml.GetRecord.record.metadata.oai_dc_dc; var test = xml..responseDate.text().toString(); if (citation.dc_title.length()){ title = Zotero.Utilities.trimInternal(citation.dc_title.text().toString()); newItem.title = title; } Zotero.debug("article title: " + title); var type = ""; if(citation.dc_creator.length()) { var authors = citation.dc_creator; for(var j=0; j