-- 62 -- Set the following timestamp to the most recent scraper update date REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-15 15:42:00')); REPLACE INTO "translators" VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '2006-08-11 11:18:00', 4, 'Amazon.com', 'Simon Kornblith', '^http://www\.amazon\.com/(?:gp/(?:product|search)/|exec/obidos/search-handle-url/|s/)', 'function detectWeb(doc, url) { var searchRe = new RegExp(''^http://www\.amazon\.com/(gp/search/|exec/obidos/search-handle-url/|s/)''); if(searchRe.test(doc.location.href)) { return "multiple"; } else { return "book"; } } ', 'function scrape(doc) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var newItem = new Scholar.Item("book"); // Retrieve authors try { var xpath = ''/html/body/table/tbody/tr/td[2]/form/div[@class="buying"]/a/text()[1]''; var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); var elmt; while(elmt = elmts.iterateNext()) { newItem.creators.push(Scholar.Utilities.cleanAuthor(elmt.nodeValue, "author")); } } catch(ex) {Scholar.Utilities.debug(ex);} // Retrieve data from "Product Details" box var xpath = ''/html/body/table/tbody/tr/td[2]/table/tbody/tr/td[@class="bucket"]/div[@class="content"]/ul/li''; var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); var elmt; newItem.extra = ""; while(elmt = elmts.iterateNext()) { try { var attribute = Scholar.Utilities.cleanString(doc.evaluate(''./B[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); var value = Scholar.Utilities.getNodeString(doc, elmt, ''./descendant-or-self::*[name() != "B"]/text()'', nsResolver); if(value) { value = Scholar.Utilities.cleanString(value); if(attribute == "Publisher:") { if(value.lastIndexOf("(") != -1) { var date = value.substring(value.lastIndexOf("(")+1, value.length-1); jsDate = new Date(date); if(!isNaN(jsDate.valueOf())) { date = Scholar.Utilities.dateToSQL(jsDate); } newItem.date = date; value = value.substring(0, value.lastIndexOf("(")-1); } if(value.lastIndexOf(";") != -1) { newItem.edition = value.substring(value.lastIndexOf(";")+2, value.length); value = value.substring(0, value.lastIndexOf(";")); } newItem.publisher = value; } else if(attribute == "ISBN:") { newItem.ISBN = value; } else if(value.substring(value.indexOf(" ")+1, value.length) == "pages") { newItem.pages = value.substring(0, value.indexOf(" ")); } else if(attribute != "Average Customer Review:") { if(attribute == "In-Print Editions:") { value = value.replace(" | All Editions", ""); } else { value = value.replace(/\([^)]*\)/g, ""); } newItem.extra += attribute+" "+value+"\n"; } } } catch(ex) {} } if(newItem.extra) { newItem.extra = newItem.extra.substr(0, newItem.extra.length-1); } newItem.attachments.push({title:"Amazon.com Product Page", document:doc}); var xpath = ''/html/body/table/tbody/tr/td[2]/form/div[@class="buying"]/b[@class="sans"]/text()[1]''; var title = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; title = Scholar.Utilities.cleanString(title); if(title.lastIndexOf("(") != -1 && title.lastIndexOf(")") == title.length-1) { title = title.substring(0, title.lastIndexOf("(")-1); } newItem.title = title; newItem.complete(); } function doWeb(doc, url) { var searchRe = new RegExp(''^http://www\.amazon\.com/(gp/search/|exec/obidos/search-handle-url/|s/)''); var m = searchRe.exec(doc.location.href) if(m) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; // Why can''t amazon use the same stylesheets var xpath; if(m == "exec/obidos/search-handle-url/") { xpath = ''//table[@cellpadding="3"]''; } else { xpath = ''//table[@class="searchresults"]''; } var searchresults = Scholar.Utilities.gatherElementsOnXPath(doc, doc, xpath, nsResolver); var items = Scholar.Utilities.getItemArray(doc, searchresults, ''^http://www\.amazon\.com/(gp/product/|exec/obidos/tg/detail/)'', ''^(Buy new|Hardcover|Paperback|Digital)$''); items = Scholar.selectItems(items); if(!items) { return true; } var uris = new Array(); for(var i in items) { uris.push(i); } Scholar.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, function() { Scholar.done(); }, null); Scholar.wait(); } else { scrape(doc); } }'); REPLACE INTO "translators" VALUES ('838d8849-4ffb-9f44-3d0d-aa8a0a079afe', '2006-06-26 16:01:00', 4, 'WorldCat', 'Simon Kornblith', '^http://(?:new)?firstsearch\.oclc\.org/WebZ/', 'function detectWeb(doc, url) { var detailRe = /FirstSearch: [\w ]+ Detailed Record/; var searchRe = /FirstSearch: [\w ]+ List of Records/; if(detailRe.test(doc.title)) { return "book"; } else if(searchRe.test(doc.title)) { return "multiple"; } }', 'function processURLs(urls) { if(!urls.length) { // last url Scholar.done(); return; } var newUrl = urls.shift(); Scholar.Utilities.HTTP.doPost(newUrl, ''exportselect=record&exporttype=plaintext'', function(text) { var lineRegexp = new RegExp(); lineRegexp.compile("^([\\w() ]+): *(.*)$"); var newItem = new Scholar.Item("book"); newItem.extra = ""; var lines = text.split(''\n''); for(var i=0;i/; var newItem = new Scholar.Item("journalArticle"); newItem.attachments.push(getJSTORAttachment(viewPages[k])); for(var i in lines) { if(lines[i].substring(0,3) == "<1>") { haveStarted = true; } else if(newItemRe.test(lines[i])) { itemComplete(newItem, url); k++; newItem = new Scholar.Item("journalArticle"); newItem.attachments.push(getJSTORAttachment(viewPages[k])); } else if(lines[i].substring(2, 5) == " : " && haveStarted) { var fieldCode = lines[i].substring(0, 2); var fieldContent = Scholar.Utilities.cleanString(lines[i].substring(5)) if(fieldCode == "TI") { if(fieldContent) { newItem.title = fieldContent; } else { newItem.title = "[untitled]"; } } else if(fieldCode == "AU") { var authors = fieldContent.split(";"); for(j in authors) { if(authors[j]) { newItem.creators.push(Scholar.Utilities.cleanAuthor(authors[j], "author", true)); } } } else if(fieldCode == "SO") { newItem.publicationTitle = fieldContent; } else if(fieldCode == "VO") { newItem.volume = fieldContent; } else if(fieldCode == "NO") { newItem.issue = fieldContent; } else if(fieldCode == "SE") { newItem.seriesTitle = fieldContent; } else if(fieldCode == "DA") { var date = new Date(fieldContent.replace(".", "")); if(isNaN(date.valueOf())) { newItem.date = fieldContent; } else { newItem.date = Scholar.Utilities.dateToSQL(date); } } else if(fieldCode == "PP") { newItem.pages = fieldContent; } else if(fieldCode == "EI") { newItem.url = fieldContent; } else if(fieldCode == "IN") { newItem.ISSN = fieldContent; } else if(fieldCode == "PB") { newItem.publisher = fieldContent; } } } // last item is complete if(haveStarted) { itemComplete(newItem, url); } Scholar.done(); }); }); }); Scholar.wait(); }'); REPLACE INTO "translators" VALUES ('e85a3134-8c1a-8644-6926-584c8565f23e', '2006-06-26 16:01:00', 4, 'History Cooperative', 'Simon Kornblith', '^http://www\.historycooperative\.org/(?:journals/.+/.+/.+\.s?html$|cgi-bin/search.cgi)', 'function detectWeb(doc, url) { if(doc.title == "History Cooperative: Search Results") { return "multiple"; } else { return "journalArticle"; } }', 'function associateMeta(newItem, metaTags, field, scholarField) { var field = metaTags.namedItem(field); if(field) { newItem[scholarField] = field.getAttribute("content"); } } function scrape(doc) { var newItem = new Scholar.Item("journalArticle"); newItem.url = doc.location.href; var month, year; var metaTags = doc.getElementsByTagName("meta"); associateMeta(newItem, metaTags, "Title", "title"); associateMeta(newItem, metaTags, "Journal", "publicationTitle"); associateMeta(newItem, metaTags, "Volume", "volume"); associateMeta(newItem, metaTags, "Issue", "issue"); var author = metaTags.namedItem("Author"); if(author) { var authors = author.getAttribute("content").split(" and "); for(j in authors) { newItem.creators.push(Scholar.Utilities.cleanAuthor(authors[j], "author")); } } var month = metaTags.namedItem("PublicationMonth"); var year = metaTags.namedItem("PublicationYear"); if(month && year) { newItem.date = month.getAttribute("content")+" "+year.getAttribute("content"); } newItem.attachments.push({document:doc, title:"History Cooperative Full Text", downloadable:true}); newItem.complete(); } function doWeb(doc, url) { if(doc.title == "History Cooperative: Search Results") { var items = Scholar.Utilities.getItemArray(doc, doc, ''^http://[^/]+/journals/.+/.+/.+\.html$''); items = Scholar.selectItems(items); if(!items) { return true; } var uris = new Array(); for(var i in items) { uris.push(i); } Scholar.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, function() { Scholar.done(); }, null); Scholar.wait(); } else { scrape(doc); } }'); REPLACE INTO "translators" VALUES ('4fd6b89b-2316-2dc4-fd87-61a97dd941e8', '2006-08-06 21:45:00', 4, 'InnoPAC', 'Simon Kornblith', '^http://[^/]+/(?:search/|record=)', 'function detectWeb(doc, url) { // First, check to see if the URL alone reveals InnoPAC, since some sites don''t reveal the MARC button var matchRegexp = new RegExp(''^(http://[^/]+/search/[^/]+/[^/]+/1\%2C[^/]+/)frameset(.+)$''); if(matchRegexp.test(doc.location.href)) { return "book"; } // Next, look for the MARC button var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var xpath = ''//a[img[@src="/screens/marcdisp.gif" or @alt="MARC Display" or @src="/screens/regdisp.gif" or @alt="REGULAR RECORD DISPLAY"]]''; var elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(elmt) { return "book"; } // Also, check for links to an item display page var tags = doc.getElementsByTagName("a"); for(var i=0; i 1) { postString += "save_func=save_marked"; Scholar.Utilities.HTTP.doGet(clearUrl, function() { Scholar.Utilities.HTTP.doPost(postUrl, postString, function() { Scholar.Utilities.HTTP.doPost(exportUrl, "ex_format=50&ex_device=45&SUBMIT=Submit", function(text) { var notSpace = /[^\s]/ if(notSpace.test(text)) { marc.setString(text); marc.translate(); Scholar.done(); } else { pageByPage(marc, newUrls); } }); }); }); } else { pageByPage(marc, newUrls); } } Scholar.wait(); }'); REPLACE INTO "translators" VALUES ('add7c71c-21f3-ee14-d188-caf9da12728b', '2006-06-26 16:01:00', 4, 'SIRSI 2003+', 'Simon Kornblith', '/uhtbin/cgisirsi', 'function detectWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var xpath = ''//tr[th[@class="viewmarctags"]][td[@class="viewmarctags"]]''; if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { return "book"; } var xpath = ''//td[@class="searchsum"]/table''; if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { return "multiple"; } }', 'function scrape(doc) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var xpath = ''//tr[th[@class="viewmarctags"]][td[@class="viewmarctags"]]''; var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); var elmt = elmts.iterateNext(); if(!elmt) { return false; } var newItem = new Scholar.Item("book"); newItem.extra = ""; while(elmt) { try { var node = doc.evaluate(''./TD[1]/A[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(!node) { var node = doc.evaluate(''./TD[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); } if(node) { var casedField = Scholar.Utilities.superCleanString(doc.evaluate(''./TH[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); field = casedField.toLowerCase(); var value = Scholar.Utilities.superCleanString(node.nodeValue); if(field == "publisher") { newItem.publisher = value; } else if(field == "pub date") { var re = /[0-9]+/; var m = re.exec(value); newItem.date = m[0]; } else if(field == "isbn") { var re = /^[0-9](?:[0-9X]+)/; var m = re.exec(value); newItem.ISBN = m[0]; } else if(field == "title") { var titleParts = value.split(" / "); newItem.title = titleParts[0]; } else if(field == "publication info") { var pubParts = value.split(" : "); newItem.place = pubParts[0]; } else if(field == "personal author") { newItem.creators.push(Scholar.Utilities.cleanAuthor(value, "author", true)); } else if(field == "added author") { newItem.creators.push(Scholar.Utilities.cleanAuthor(value, "contributor", true)); } else if(field == "corporate author") { newItem.creators.push({lastName:author}); } else if(field == "subject term" || field == "corporate subject" || field == "geographic term") { var subjects = value.split("--"); newItem.tags = newItem.tags.concat(subjects); } else if(field == "personal subject") { var subjects = value.split(", "); newItem.tags = newItem.tags.push(value[0]+", "+value[1]); } else if(value && field != "http") { newItem.extra += casedField+": "+value+"\n"; } } } catch (e) {} elmt = elmts.iterateNext(); } if(newItem.extra) { newItem.extra = newItem.extra.substr(0, newItem.extra.length-1); } var callNumber = doc.evaluate(''//tr/td[1][@class="holdingslist"]/text()'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(callNumber && callNumber.nodeValue) { newItem.callNumber = callNumber.nodeValue; } newItem.complete(); return true; } function doWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; if(!scrape(doc)) { var checkboxes = new Array(); var urls = new Array(); var availableItems = new Array(); var tableRows = doc.evaluate(''//td[@class="searchsum"]/table[//input[@value="Details"]]'', doc, nsResolver, XPathResult.ANY_TYPE, null); var tableRow = tableRows.iterateNext(); // skip first row // Go through table rows while(tableRow = tableRows.iterateNext()) { var input = doc.evaluate(''.//input[@value="Details"]'', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); var text = Scholar.Utilities.getNodeString(doc, tableRow, ''.//label/strong//text()'', nsResolver); if(text) { availableItems[input.name] = text; } } var items = Scholar.selectItems(availableItems); if(!items) { return true; } var hostRe = new RegExp("^http://[^/]+"); var m = hostRe.exec(doc.location.href); var hitlist = doc.forms.namedItem("hitlist"); var baseUrl = m[0]+hitlist.getAttribute("action")+"?first_hit="+hitlist.elements.namedItem("first_hit").value+"&last_hit="+hitlist.elements.namedItem("last_hit").value; var uris = new Array(); for(var i in items) { uris.push(baseUrl+"&"+i+"=Details"); } Scholar.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, function() { Scholar.done() }, null); Scholar.wait(); } }'); REPLACE INTO "translators" VALUES ('a77690cf-c5d1-8fc4-110f-d1fc765dcf88', '2006-06-26 16:01:00', 4, 'ProQuest', 'Simon Kornblith', '^http://[^/]+/pqdweb\?((?:.*\&)?did=.*&Fmt=[0-9]|(?:.*\&)Fmt=[0-9].*&did=|(?:.*\&)searchInterface=)', 'function detectWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; if(doc.evaluate(''//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]'', doc, nsResolver, XPathResult.ANY_TYPE, null)) { if(doc.title == "Results") { return "multiple"; } else { return "magazineArticle"; } } }', 'function scrape(doc) { Scholar.Utilities.debug(doc.getElementsByTagName("body")[0].innerHTML); var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var newItem = new Scholar.Item(); var elmt; // Title var xpath = ''/html/body/span[@class="textMedium"]/table/tbody/tr/td[@class="headerBlack"]/strong//text()''; newItem.title = Scholar.Utilities.getNodeString(doc, doc, xpath, nsResolver); // Authors var xpath = ''/html/body/span[@class="textMedium"]/table/tbody/tr/td[@class="textMedium"]/a/em''; var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); while(elmt = elmts.iterateNext()) { // there are sometimes additional tags representing higlighting var author = Scholar.Utilities.getNodeString(doc, elmt, ''.//text()'', nsResolver); if(author) { newItem.creators.push(Scholar.Utilities.cleanAuthor(author, "author")); } } // Other info var xpath = ''/html/body/span[@class="textMedium"]/font/table/tbody/tr''; var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); while(elmt = elmts.iterateNext()) { var field = Scholar.Utilities.superCleanString(doc.evaluate(''./TD[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue).toLowerCase(); if(field == "publication title") { var publication = doc.evaluate(''./TD[2]/A[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(publication.nodeValue) { newItem.publicationTitle = Scholar.Utilities.superCleanString(publication.nodeValue); } var place = doc.evaluate(''./TD[2]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(place.nodeValue) { newItem.place = Scholar.Utilities.superCleanString(place.nodeValue); } var date = doc.evaluate(''./TD[2]/A[2]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(date.nodeValue) { date = date.nodeValue; var jsDate = new Date(Scholar.Utilities.superCleanString(date)); if(!isNaN(jsDate.valueOf())) { date = Scholar.Utilities.dateToSQL(jsDate); } newItem.date = date; } var moreInfo = doc.evaluate(''./TD[2]/text()[2]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(moreInfo.nodeValue) { moreInfo = Scholar.Utilities.superCleanString(moreInfo.nodeValue); var parts = moreInfo.split(";\xA0"); var issueRegexp = /^(\w+)\.(?: |\xA0)?(.+)$/ var issueInfo = parts[0].split(",\xA0"); for(j in issueInfo) { var m = issueRegexp.exec(issueInfo[j]); if(m) { var info = m[1].toLowerCase(); if(info == "vol") { newItem.volume = Scholar.Utilities.superCleanString(m[2]); } else if(info == "iss" || info == "no") { newItem.issue = Scholar.Utilities.superCleanString(m[2]); } } } if(parts[1] && Scholar.Utilities.superCleanString(parts[1]).substring(0, 3).toLowerCase() == "pg.") { var re = /[0-9\-]+/; var m = re.exec(parts[1]); if(m) { newItem.pages = m[0]; } } } } else if(field == "source type") { var value = doc.evaluate(''./TD[2]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(value.nodeValue) { value = Scholar.Utilities.superCleanString(value.nodeValue).toLowerCase(); if(value.indexOf("periodical") >= 0) { newItem.itemType = "magazineArticle"; } else if(value.indexOf("newspaper") >= 0) { newItem.itemType = "newspaperArticle"; } else { // TODO: support thesis newItem.itemType = "book"; } } } else if(field == "isbn" || field == "issn" || field == "issn/isbn") { var value = doc.evaluate(''./TD[2]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(value) { var type; value = Scholar.Utilities.superCleanString(value.nodeValue); if(value.length == 10 || value.length == 13) { newItem.ISBN = value; } else if(value.length == 8) { newItem.ISSN = value; } } } else if(field == "document url") { var value = doc.evaluate(''./TD[2]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(value) { newItem.url = Scholar.Utilities.cleanString(value.nodeValue); } } else if(field == "proquest document id") { var value = doc.evaluate(''./TD[2]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(value) { newItem.accessionNumber = Scholar.Utilities.cleanString(value.nodeValue); } } else if(field == "subjects" || field == "people" || field == "locations") { var subjects = doc.evaluate(".//a", elmt, nsResolver, XPathResult.ANY_TYPE, null); var currentSubject; while(currentSubject = subjects.iterateNext()) { var subjectValue = Scholar.Utilities.getNodeString(doc, currentSubject, ".//text()", nsResolver); subjectValue = Scholar.Utilities.superCleanString(subjectValue); if(subjectValue) { newItem.tags.push(subjectValue); } } } } // magazineArticle -> journalArticle if issue and volume exist if(newItem.itemType == "magazineArticle" && (newItem.issue || newItem.volume)) { newItem.itemType = "journalArticle"; } // figure out what we can attach var attachArray = { ''//td[@class="textSmall"]//img[@alt="Full Text - PDF"]'':"ProQuest Full Text (PDF)", ''//td[@class="textSmall"]//img[@alt="Text+Graphics"]'':"ProQuest Full Text (HTML with Graphics)", ''//td[@class="textSmall"]//img[@alt="Full Text"]'':"ProQuest Full Text (HTML)", ''//td[@class="textSmall"]//img[@alt="Abstract"]'':"ProQuest Abstract" } for(var xpath in attachArray) { var item = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(item) { var title = attachArray[xpath]; if(item.parentNode.tagName.toLowerCase() == "a") { // item is not this page newItem.attachments.push({url:item.parentNode.href, title:title, mimeType:(title == "ProQuest Full Text (PDF)" ? "application/pdf" : "text/html"), downloadable:true}); } else { // item is this page newItem.attachments.push({document:doc, title:title, downloadable:true}); } } } newItem.complete(); } function doWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; if(doc.title == "Results") { var items = new Object(); // Require link to match this var tagRegexp = new RegExp(); tagRegexp.compile(''^http://[^/]+/pqdweb\\?((?:.*&)?did=.*&Fmt=[12](?:[^0-9]|$)|(?:.*&)Fmt=[12][^0-9].*&did=)''); var tableRows = doc.evaluate(''//tr[@class="rowUnMarked"]'', doc, nsResolver, XPathResult.ANY_TYPE, null); // Go through table rows var tableRow; while(tableRow = tableRows.iterateNext()) { var links = tableRow.getElementsByTagName("a"); // Go through links for(var j=0; j]*>/gi); newItem.publicationTitle = elementParts[elementParts.length-1]; var dateRegexp = /]*>(?:)?([A-Z][a-z]+)(?:<\/b>)? ([0-9]+, [0-9]{4})/; var m = dateRegexp.exec(centerElements[centerElements.length-1].innerHTML); if(m) { var jsDate = new Date(m[1]+" "+m[2]); newItem.date = Scholar.Utilities.dateToSQL(jsDate); } else { var elementParts = centerElements[centerElements.length-1].innerHTML.split(/]*>/gi); newItem.date = elementParts[1]; } var cutIndex = citationDataDiv.innerHTML.indexOf("BODY:"); if(cutIndex < 0) { cutIndex = citationDataDiv.innerHTML.indexOf("TEXT:"); } if(cutIndex > 0) { citationData = citationDataDiv.innerHTML.substring(0, cutIndex); } else { citationData = citationDataDiv.innerHTML; } citationData = Scholar.Utilities.cleanTags(citationData); var headlineRegexp = /\n(?:HEADLINE|TITLE|ARTICLE): ([^\n]+)\n/; var m = headlineRegexp.exec(citationData); if(m) { newItem.title = Scholar.Utilities.cleanTags(m[1]); } var bylineRegexp = /\nBYLINE: *(\w[\w\- ]+)/; var m = bylineRegexp.exec(citationData); if(m) { // there is a byline; use it as an author if(m[1].substring(0, 3).toLowerCase() == "by ") { m[1] = m[1].substring(3); } newItem.creators.push(Scholar.Utilities.cleanAuthor(m[1], "author")); newItem.itemType = "newspaperArticle"; } else { // no byline; must be a journal newItem.itemType = "journalArticle"; } // other ways authors could be encoded var authorRegexp = /\n(?:AUTHOR|NAME): ([^\n]+)\n/; var m = authorRegexp.exec(citationData); if(m) { var authors = m[1].split(/, (?:and )?/); for(var i in authors) { newItem.creators.push(Scholar.Utilities.cleanAuthor(authors[i].replace(" *", ""), "author")); } } newItem.complete(); } function doWeb(doc, url) { var detailRe = new RegExp("^http://[^/]+/universe/document"); if(detailRe.test(doc.location.href)) { scrape(doc); } else { var items = Scholar.Utilities.getItemArray(doc, doc, "^http://[^/]+/universe/document"); items = Scholar.selectItems(items); if(!items) { return true; } var uris = new Array(); for(var i in items) { uris.push(i); } Scholar.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, function() { Scholar.done(); }, null); Scholar.wait(); } }'); REPLACE INTO "translators" VALUES ('cf87eca8-041d-b954-795a-2d86348999d5', '2006-06-26 16:01:00', 4, 'Aleph', 'Simon Kornblith', '^http://[^/]+/F(?:/[A-Z0-9\-]+(?:\?.*)?$|\?func=find)', 'function detectWeb(doc, url) { var singleRe = new RegExp("^http://[^/]+/F/[A-Z0-9\-]+\?.*func=full-set-set.*\&format=[0-9]{3}"); if(singleRe.test(doc.location.href)) { return "book"; } else { var tags = doc.getElementsByTagName("a"); for(var i=0; i 3) { ind = field[3]; if(field.length > 4) { ind += field[4]; } } record.addField(code, ind, value); } } var newItem = new Scholar.Item(); record.translate(newItem); newItem.complete(); }, function() { Scholar.done(); }, null); Scholar.wait(); }'); REPLACE INTO "translators" VALUES ('774d7dc2-3474-2684-392c-f787789ec63d', '2006-06-26 16:01:00', 4, 'Dynix', 'Simon Kornblith', 'ipac\.jsp\?.*(?:uri=full=[0-9]|menu=search)', 'function detectWeb(doc, url) { var detailsRe = new RegExp(''ipac\.jsp\?.*uri=full=[0-9]''); if(detailsRe.test(doc.location.href)) { return "book"; } else { return "multiple"; } }', 'function doWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var uri = doc.location.href; var detailsRe = new RegExp(''ipac\.jsp\?.*uri=full=[0-9]''); var uris = new Array(); if(detailsRe.test(uri)) { uris.push(uri+''&fullmarc=true''); } else { var items = Scholar.Utilities.getItemArray(doc, doc, "ipac\.jsp\?.*uri=full=[0-9]|^javascript:buildNewList\\(''.*uri%3Dfull%3D[0-9]"); items = Scholar.selectItems(items); if(!items) { return true; } var buildNewList = new RegExp("^javascript:buildNewList\\(''([^'']+)"); var uris = new Array(); for(var i in items) { var m = buildNewList.exec(i); if(m) { uris.push(unescape(m[1]+''&fullmarc=true'')); } else { uris.push(i+''&fullmarc=true''); } } } var translator = Scholar.loadTranslator("import"); translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); var marc = translator.getTranslatorObject(); Scholar.Utilities.processDocuments(uris, function(newDoc) { var uri = newDoc.location.href; var namespace = newDoc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var xpath = ''//form/table[@class="tableBackground"]/tbody/tr/td/table[@class="tableBackground"]/tbody/tr[td[1]/a[@class="normalBlackFont1"]]''; var elmts = newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null); var elmt; var record = new marc.record(); while(elmt = elmts.iterateNext()) { var field = Scholar.Utilities.superCleanString(newDoc.evaluate(''./TD[1]/A[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); var value = Scholar.Utilities.getNodeString(newDoc, elmt, ''./TD[2]/TABLE[1]/TBODY[1]/TR[1]/TD[1]/A[1]//text()'', nsResolver); if(field == "LDR") { record.leader = value; } else if(field != "FMT") { value = value.replace(/\$([a-z]) /g, marc.subfieldDelimiter+"$1"); var code = field.substring(0, 3); var ind = ""; if(field.length > 3) { ind = field[3]; if(field.length > 4) { ind += field[4]; } } record.addField(code, ind, value); } } var newItem = new Scholar.Item(); record.translate(newItem); newItem.complete(); }, function() { Scholar.done() }, null); Scholar.wait(); }'); REPLACE INTO "translators" VALUES ('63a0a351-3131-18f4-21aa-f46b9ac51d87', '2006-06-26 16:01:00', 4, 'VTLS', 'Simon Kornblith', '/chameleon(?:\?|$)', 'function detectWeb(doc, url) { var node = doc.evaluate(''//tr[@class="intrRow"]/td/table/tbody/tr[th]'', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); if(node) { return "multiple"; } var node = doc.evaluate(''//a[text()="marc"]'', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); if(node) { return "book"; } }', 'function doWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var uri = doc.location.href; var newUris = new Array(); var marcs = doc.evaluate(''//a[text()="marc"]'', doc, nsResolver, XPathResult.ANY_TYPE, null); var record = marcs.iterateNext(); if(record && !marcs.iterateNext()) { newUris.push(record.href); } else { // Require link to match this var tagRegexp = new RegExp(); tagRegexp.compile("/chameleon\?.*function=CARDSCR"); var items = new Array(); var tableRows = doc.evaluate(''//tr[@class="intrRow"]'', doc, nsResolver, XPathResult.ANY_TYPE, null); var tableRow // Go through table rows while(tableRow = tableRows.iterateNext()) { var links = tableRow.getElementsByTagName("a"); // Go through links var url; for(var j=0; j 0) { return "multiple"; } else { return "book"; } }', 'function doWeb(doc, url) { var checkItems = false; if(doc.location.href.indexOf("/authority_hits") > 0) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; checkItems = Scholar.Utilities.gatherElementsOnXPath(doc, doc, "/html/body//ol/li", nsResolver); } if(checkItems && checkItems.length) { var items = Scholar.Utilities.getItemArray(doc, checkItems, ''https?://.*/web2/tramp2\.exe/see_record''); items = Scholar.selectItems(items); if(!items) { return true; } var uris = new Array(); for(var i in items) { uris.push(i); } } else { var ug = new Array(doc.location.href); } for(var i in uris) { var uri = uris[i]; var uriRegexp = /^(https?:\/\/.*\/web2\/tramp2\.exe\/)(?:goto|see\_record|authority\_hits)(\/.*)\?(?:screen=Record\.html\&)?(.*)$/i; var m = uriRegexp.exec(uri); if(uri.indexOf("/authority_hits") < 0) { var newUri = m[1]+"download_record"+m[2]+"/RECORD.MRC?format=marc&"+m[3]; } else { var newUri = m[1]+"download_record"+m[2]+"/RECORD.MRC?format=marc"; } // Keep track of how many requests have been completed var j = 0; var translator = Scholar.loadTranslator("import"); translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); Scholar.Utilities.HTTP.doGet(newUri, function(text) { translator.setString(text); translator.translate(); j++; if(j == uris.length) { Scholar.done(); } }); } Scholar.wait(); }'); REPLACE INTO "translators" VALUES ('c0e6fda6-0ecd-e4f4-39ca-37a4de436e15', '2006-06-26 16:01:00', 4, 'GEAC', 'Simon Kornblith', '/(?:GeacQUERY|GeacFETCH[\:\?].*[&:]next=html/(?:record\.html|geacnffull\.html))', 'function detectWeb(doc, url) { if(doc.location.href.indexOf("/GeacQUERY") > 0) { return "multiple"; } else { return "book"; } }', 'function doWeb(doc, url) { var uri = doc.location.href; var uris = new Array(); if(uri.indexOf("/GeacQUERY") > 0) { var items = Scholar.Utilities.getItemArray(doc, doc, "(?:Geac)?FETCH[\:\?].*[&:]next=html/(?:record\.html|geacnffull\.html)"); items = Scholar.selectItems(items); if(!items) { return true; } var uris = new Array(); for(var i in items) { var newUri = i.replace(/([:&])next=html\/geacnffull.html/, "$1next=html/marc.html"); newUri = newUri.replace(/([:&])next=html\/record.html/, "$1next=html/marc.html"); uris.push(newUri); } } else { var newUri = uri.replace(/([:&])next=html\/geacnffull.html/, "$1next=html/marc.html"); newUri = newUri.replace(/([:&])next=html\/record.html/, "$1next=html/marc.html"); uris.push(newUri); } var translator = Scholar.loadTranslator("import"); translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); var marc = translator.getTranslatorObject(); Scholar.Utilities.processDocuments(uris, function(newDoc) { var uri = newDoc.location.href; var namespace = newDoc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var record = new marc.record(); var elmts = newDoc.evaluate(''//pre/text()'', newDoc, nsResolver, XPathResult.ANY_TYPE, null); var elmt, tag, content; var ind = ""; while(elmt = elmts.iterateNext()) { var line = elmt.nodeValue; if(line.substring(0, 6) == " ") { content += " "+line.substring(6); continue; } else { if(tag) { record.addField(tag, ind, content); } } line = line.replace(/[_\t\xA0]/g," "); // nbsp tag = line.substr(0, 3); if(tag[0] != "0" || tag[1] != "0") { ind = line.substr(4, 2); content = line.substr(7).replace(/\$([a-z])(?: |$)/g, marc.subfieldDelimiter+"$1"); } else { if(tag == "000") { tag = undefined; record.leader = "00000"+line.substr(4); } else { content = line.substr(4); } } } var newItem = new Scholar.Item(); record.translate(newItem); newItem.complete(); }, function() { Scholar.done(); }, null); Scholar.wait(); }'); REPLACE INTO "translators" VALUES ('5287d20c-8a13-6004-4dcb-5bb2b66a9cc9', '2006-06-26 16:01:00', 4, 'SIRSI -2003', 'Simon Kornblith', '/uhtbin/cgisirsi', 'function detectWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var elmts = doc.evaluate(''/html/body/form/p/text()[1]'', doc, nsResolver, XPathResult.ANY_TYPE, null); var elmt; while(elmt = elmts.iterateNext()) { if(Scholar.Utilities.superCleanString(elmt.nodeValue) == "Viewing record") { return "book"; } } var xpath = ''//form[@name="hitlist"]/table/tbody/tr''; var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); if(elmts.iterateNext()) { return "multiple"; } }', 'function doWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; var uri = doc.location.href; var recNumbers = new Array(); var xpath = ''//form[@name="hitlist"]/table/tbody/tr''; var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); var elmt = elmts.iterateNext(); if(elmt) { // Search results page var uriRegexp = /^http:\/\/[^\/]+/; var m = uriRegexp.exec(uri); var postAction = doc.forms.namedItem("hitlist").getAttribute("action"); var newUri = m[0]+postAction.substr(0, postAction.length-1)+"40" var titleRe = /
\s*(.*[^\s])\s*
/i; var items = new Array(); do { var checkbox = doc.evaluate(''.//input[@type="checkbox"]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); // Collect title var title = Scholar.Utilities.getNodeString(doc, elmt, "./td[2]/text()", nsResolver); if(checkbox && title) { items[checkbox.name] = Scholar.Utilities.cleanString(title); } } while(elmt = elmts.iterateNext()); items = Scholar.selectItems(items); if(!items) { return true; } for(var i in items) { recNumbers.push(i); } } else { // Normal page var uriRegexp = /^(.*)(\/[0-9]+)$/; var m = uriRegexp.exec(uri); var newUri = m[1]+"/40" var elmts = doc.evaluate(''/html/body/form/p'', doc, nsResolver, XPathResult.ANY_TYPE, null); while(elmt = elmts.iterateNext()) { var initialText = doc.evaluate(''./text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(initialText && initialText.nodeValue && Scholar.Utilities.superCleanString(initialText.nodeValue) == "Viewing record") { recNumbers.push(doc.evaluate(''./b[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); break; } } } var translator = Scholar.loadTranslator("import"); translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); var marc = translator.getTranslatorObject(); Scholar.Utilities.loadDocument(newUri+''?marks=''+recNumbers.join(",")+''&shadow=NO&format=FLAT+ASCII&sort=TITLE&vopt_elst=ALL&library=ALL&display_rule=ASCENDING&duedate_code=l&holdcount_code=t&DOWNLOAD_x=22&DOWNLOAD_y=12&address=&form_type='', function(doc) { var pre = doc.getElementsByTagName("pre"); var text = pre[0].textContent; var documents = text.split("*** DOCUMENT BOUNDARY ***"); for(var j=1; j]*>/, "").replace(/<\?xml[^>]*\?>/, ""); var xml = new XML(text); for(var i=0; i 1) { var selectArray = new Array(); for(var i in newItems) { selectArray[i] = newItems[i].title; } selectArray = Scholar.selectItems(selectArray); for(var i in selectArray) { // add doc as attachment newItems[i].attachments.push({document:doc}); newItems[i].complete(); } } else if(newItems.length) { newItems[0].attachments.push({document:doc}); newItems[0].complete(); } } function doWeb(doc, url) { var newItems = new Array(); var needFullItems = new Array(); var spanTags = doc.getElementsByTagName("span"); for(var i=0; i/ var eventValidationMatch = // Scholar.Utilities.HTTP.doPost(url, saveString, function() { // mark records Scholar.Utilities.HTTP.doPost(url, folderString, function(text) { var postLocation = /
]*>/gi; var nameRe = /name="([^"]+)"/i; var contentRe = /content="([^"]+)"/i; var m = doc.match(metaTagRe); if(!m) { return; } for(var i=0; i]*\?>/, ""); // parse XML with E4X var qr = new Namespace("http://www.crossref.org/qrschema/2.0"); try { var xml = new XML(xmlOutput); } catch(e) { return false; } // ensure status is valid var status = xml.qr::query_result.qr::body.qr::query.@status.toString(); if(status != "resolved" && status != "multiresolved") { return false; } var query = xml.qr::query_result.qr::body.qr::query; var item = new Scholar.Item("journalArticle"); // try to get a DOI item.DOI = query.qr::doi.(@type=="journal_article").text().toString(); if(!item.DOI) { item.DOI = query.qr::doi.(@type=="book_title").text().toString(); } if(!item.DOI) { item.DOI = query.qr::doi.(@type=="book_content").text().toString(); } // try to get an ISSN (no print/electronic preferences) item.ISSN = query.qr::issn[0].text().toString(); // get title item.title = query.qr::article_title.text().toString(); // get publicationTitle item.publicationTitle = query.qr::journal_title.text().toString(); // get author item.creators.push(Scholar.Utilities.cleanAuthor(query.qr::author.text().toString(), "author", true)); // get volume item.volume = query.qr::volume.text().toString(); // get issue item.issue = query.qr::issue.text().toString(); // get year item.date = query.qr::year.text().toString(); // get edition item.edition = query.qr::edition_number.text().toString(); // get first page item.pages = query.qr::first_page.text().toString(); item.complete(); return true; } function doSearch(item) { if(item.contextObject) { var co = item.contextObject; if(co.indexOf("url_ver=") == -1) { co = "url_ver=Z39.88-2004"+co; } } else { var co = Scholar.Utilities.createContextObject(item); } Scholar.Utilities.HTTP.doGet("http://www.crossref.org/openurl/?"+co+"&noredirect=true", function(responseText) { processCrossRef(responseText); Scholar.done(); }); Scholar.wait(); }'); REPLACE INTO "translators" VALUES ('0e2235e7-babf-413c-9acf-f27cce5f059c', '2006-07-05 23:40:00', 3, 'MODS (XML)', 'Simon Kornblith', 'xml', 'Scholar.addOption("exportNotes", true); function detectImport() { var read = Scholar.read(512); var modsTagRegexp = /]+>/ if(modsTagRegexp.test(read)) { return true; } }', 'var partialItemTypes = ["bookSection", "journalArticle", "magazineArticle", "newspaperArticle"]; function doExport() { var modsCollection = ; var item; while(item = Scholar.nextItem()) { var isPartialItem = Scholar.Utilities.inArray(item.itemType, partialItemTypes); var mods = ; /** CORE FIELDS **/ // XML tag titleInfo; object field title if(item.title) { mods.titleInfo.title = item.title; } // XML tag typeOfResource/genre; object field type var modsType, marcGenre; if(item.itemType == "book" || item.itemType == "bookSection") { modsType = "text"; marcGenre = "book"; } else if(item.itemType == "journalArticle" || item.itemType == "magazineArticle") { modsType = "text"; marcGenre = "periodical"; } else if(item.itemType == "newspaperArticle") { modsType = "text"; marcGenre = "newspaper"; } else if(item.itemType == "thesis") { modsType = "text"; marcGenre = "theses"; } else if(item.itemType == "letter") { modsType = "text"; marcGenre = "letter"; } else if(item.itemType == "manuscript") { modsType = "text"; modsType.@manuscript = "yes"; } else if(item.itemType == "interview") { modsType = "text"; marcGenre = "interview"; } else if(item.itemType == "film") { modsType = "moving image"; marcGenre = "motion picture"; } else if(item.itemType == "artwork") { modsType = "still image"; marcGenre = "art original"; } else if(item.itemType == "website") { modsType = "multimedia"; marcGenre = "web site"; } else if(item.itemType == "note") { continue; } mods.typeOfResource = modsType; mods.genre += {item.itemType}; if(marcGenre) { mods.genre += {marcGenre}; } // XML tag genre; object field thesisType, type if(item.thesisType) { mods.genre += {item.thesisType}; } if(item.type) { mods.genre += {item.type}; } // XML tag name; object field creators for(var j in item.creators) { var roleTerm = ""; if(item.creators[j].creatorType == "author") { roleTerm = "aut"; } else if(item.creators[j].creatorType == "editor") { roleTerm = "edt"; } else if(item.creators[j].creatorType == "creator") { roleTerm = "ctb"; } // FIXME - currently all names are personal mods.name += {item.creators[j].lastName} {item.creators[j].firstName} {roleTerm} ; } // XML tag recordInfo.recordOrigin; used to store our generator note //mods.recordInfo.recordOrigin = "Scholar for Firefox "+Scholar.Utilities.getVersion(); /** FIELDS ON NEARLY EVERYTHING BUT NOT A PART OF THE CORE **/ // XML tag recordInfo.recordContentSource; object field source if(item.source) { mods.recordInfo.recordContentSource = item.source; } // XML tag recordInfo.recordIdentifier; object field accessionNumber if(item.accessionNumber) { mods.recordInfo.recordIdentifier = item.accessionNumber; } // XML tag accessCondition; object field rights if(item.rights) { mods.accessCondition = item.rights; } /** SUPPLEMENTAL FIELDS **/ // XML tag relatedItem.titleInfo; object field series if(item.seriesTitle) { var series = {item.seriesTitle} ; if(item.itemType == "bookSection") { // For a book section, series info must go inside host tag mods.relatedItem.relatedItem = series; } else { mods.relatedItem += series; } } // Make part its own tag so we can figure out where it goes later var part = new XML(); // XML tag detail; object field volume if(item.volume) { if(Scholar.Utilities.isInt(item.volume)) { part += {item.volume}; } else { part += {item.volume}; } } // XML tag detail; object field number if(item.issue) { if(Scholar.Utilities.isInt(item.issue)) { part += {item.issue}; } else { part += {item.issue}; } } // XML tag detail; object field section if(item.section) { if(Scholar.Utilities.isInt(item.section)) { part += {item.section}; } else { part += {item.section}; } } // XML tag detail; object field pages if(item.pages) { var range = Scholar.Utilities.getPageRange(item.pages); part += {range[0]}{range[1]}; } // Assign part if something was assigned if(part.length() != 1) { if(isPartialItem) { // For a journal article, bookSection, etc., the part is the host mods.relatedItem.part += {part}; } else { mods.part += {part}; } } // XML tag originInfo; object fields edition, place, publisher, year, date var originInfo = new XML(); if(item.edition) { originInfo += {item.edition}; } if(item.place) { originInfo += {item.place}; } if(item.publisher) { originInfo += {item.publisher}; } else if(item.distributor) { originInfo += {item.distributor}; } if(item.date) { if(Scholar.Utilities.inArray(item.itemType, ["book", "bookSection"])) { // Assume year is copyright date var dateType = "copyrightDate"; } else if(Scholar.Utilities.inArray(item.itemType, ["journalArticle", "magazineArticle", "newspaperArticle"])) { // Assume date is date issued var dateType = "dateIssued"; } else { // Assume date is date created var dateType = "dateCreated"; } var tag = <{dateType}>{item.date}; tag.@encoding = "iso8601"; originInfo += tag; } if(item.accessDate) { originInfo += {item.accessDate}; } if(originInfo.length() != 1) { if(isPartialItem) { // For a journal article, bookSection, etc., this goes under the host mods.relatedItem.originInfo += {originInfo}; } else { mods.originInfo += {originInfo}; } } // XML tag identifier; object fields ISBN, ISSN if(isPartialItem) { var identifier = mods.relatedItem; } else { var identifier = mods; } if(item.ISBN) { identifier.identifier += {item.ISBN}; } if(item.ISSN) { identifier.identifier += {item.ISSN}; } if(item.DOI) { identifier.identifier += {item.DOI}; } // XML tag relatedItem.titleInfo; object field publication if(item.publicationTitle) { mods.relatedItem.titleInfo += {item.publicationTitle}; } // XML tag classification; object field callNumber if(item.callNumber) { mods.classification = item.callNumber; } // XML tag location.physicalLocation; object field archiveLocation if(item.archiveLocation) { mods.location.physicalLocation = item.archiveLocation; } // XML tag location.url; object field archiveLocation if(item.url) { mods.location.url = item.url; } // XML tag title.titleInfo; object field journalAbbreviation if(item.journalAbbreviation) { mods.relatedItem.titleInfo += {item.journalAbbreviation}; } if(mods.relatedItem.length() == 1 && isPartialItem) { mods.relatedItem.@type = "host"; } /** NOTES **/ if(Scholar.getOption("exportNotes")) { for(var j in item.notes) { // Add note tag var note = {item.notes[j].note}; mods.note += note; } } /** TAGS **/ for(var j in item.tags) { mods.subject += {item.tags[j]}; } modsCollection.mods += mods; } Scholar.write(''''+"\n"); Scholar.write(modsCollection.toXMLString()); } function doImport() { var text = ""; var read; // read in 16384 byte increments while(read = Scholar.read(16384)) { text += read; } Scholar.Utilities.debug("read in"); // eliminate heading so we can parse as XML text = text.replace(/<\?xml[^?]+\?>/, ""); // parse with E4X var m = new Namespace("http://www.loc.gov/mods/v3"); // why does this default namespace declaration not work!? default xml namespace = m; var xml = new XML(text); for each(var mods in xml.m::mods) { Scholar.Utilities.debug("item is: "); for(var i in mods) { Scholar.Utilities.debug(i+" = "+mods[i].toString()); } var newItem = new Scholar.Item(); // title newItem.title = mods.m::titleInfo.(m::title.@type!="abbreviated").m::title; // try to get genre from local genre var localGenre = mods.m::genre.(@authority=="local").text().toString(); if(localGenre && Scholar.Utilities.itemTypeExists(localGenre)) { newItem.itemType = localGenre; } else { // otherwise, look at the marc genre var marcGenre = mods.m::genre.(@authority=="marcgt").text().toString(); if(marcGenre) { if(marcGenre == "book") { newItem.itemType = "book"; } else if(marcGenre == "periodical") { newItem.itemType = "magazineArticle"; } else if(marcGenre == "newspaper") { newItem.itemType = "newspaperArticle"; } else if(marcGenre == "theses") { newItem.itemType = "thesis"; } else if(marcGenre == "letter") { newItem.itemType = "letter"; } else if(marcGenre == "interview") { newItem.itemType = "interview"; } else if(marcGenre == "motion picture") { newItem.itemType = "film"; } else if(marcGenre == "art original") { newItem.itemType = "artwork"; } else if(marcGenre == "web site") { newItem.itemType = "website"; } } if(!newItem.itemType) { newItem.itemType = "book"; } } var isPartialItem = Scholar.Utilities.inArray(newItem.itemType, partialItemTypes); // TODO: thesisType, type for each(var name in mods.m::name) { // TODO: institutional authors var creator = new Array(); creator.firstName = name.m::namePart.(@type=="given").text().toString(); creator.lastName = name.m::namePart.(@type=="family").text().toString(); // look for roles var role = name.m::role.m::roleTerm.(@type=="code").(@authority=="marcrelator").text().toString(); if(role == "edt") { creator.creatorType = "editor"; } else if(role == "ctb") { creator.creatorType = "contributor"; } else { creator.creatorType = "author"; } newItem.creators.push(creator); } // source newItem.source = mods.m::recordInfo.m::recordContentSource.text().toString(); // accessionNumber newItem.accessionNumber = mods.m::recordInfo.m::recordIdentifier.text().toString(); // rights newItem.rights = mods.m::accessCondition.text().toString(); /** SUPPLEMENTAL FIELDS **/ // series if(newItem.itemType == "bookSection") { newItem.seriesTitle = mods.m::relatedItem.(@type=="host").m::relatedItem.(@type=="series").m::titleInfo.m::title.text().toString(); } else { newItem.seriesTitle = mods.m::relatedItem.(@type=="series").m::titleInfo.m::title.text().toString(); } // get part if(isPartialItem) { var part = mods.m::relatedItem.m::part; var originInfo = mods.m::relatedItem.m::originInfo; var identifier = mods.m::relatedItem.m::identifier; } else { var part = mods.m::part; var originInfo = mods.m::originInfo; var identifier = mods.m::identifier; } // volume newItem.volume = part.m::detail.(@type=="volume").m::number.text().toString(); if(!newItem.volume) { newItem.volume = part.m::detail.(@type=="volume").m::text.text().toString(); } // number newItem.issue = part.m::detail.(@type=="issue").m::number.text().toString(); if(!newItem.issue) { newItem.issue = part.m::detail.(@type=="issue").m::text.text().toString(); } // section newItem.section = part.m::detail.(@type=="section").m::number.text().toString(); if(!newItem.section) { newItem.section = part.m::detail.(@type=="section").m::text.text().toString(); } // pages var pagesStart = part.m::extent.(@unit=="pages").m::start.text().toString(); var pagesEnd = part.m::extent.(@unit=="pages").m::end.text().toString(); if(pagesStart || pagesEnd) { if(pagesStart && pagesEnd && pagesStart != pagesEnd) { newItem.pages = pagesStart+"-"+pagesEnd; } else { newItem.pages = pagesStart+pagesEnd; } } // edition newItem.edition = originInfo.m::edition.text().toString(); // place newItem.place = originInfo.m::place.m::placeTerm.text().toString(); // publisher/distributor newItem.publisher = newItem.distributor = originInfo.m::publisher.text().toString(); // date newItem.date = originInfo.m::copyrightDate.text().toString(); if(!newItem.date) { newItem.date = originInfo.m::dateIssued.text().toString(); if(!newItem.date) { newItem.date = originInfo.dateCreated.text().toString(); } } // lastModified newItem.lastModified = originInfo.m::dateModified.text().toString(); // accessDate newItem.accessDate = originInfo.m::dateCaptured.text().toString(); // ISBN newItem.ISBN = identifier.(@type=="isbn").text().toString() // ISSN newItem.ISSN = identifier.(@type=="issn").text().toString() // DOI newItem.DOI = identifier.(@type=="doi").text().toString() // publication newItem.publicationTitle = mods.m::relatedItem.m::publication.text().toString(); // call number newItem.callNumber = mods.m::classification.text().toString(); // archiveLocation newItem.archiveLocation = mods.m::location.m::physicalLocation.text().toString(); // url newItem.url = mods.m::location.m::url.text().toString(); // journalAbbreviation newItem.journalAbbreviation = mods.m::relatedItem.(m::titleInfo.@type=="abbreviated").m::titleInfo.m::title.text().toString(); /** NOTES **/ for each(var note in mods.m::note) { newItem.notes.push({note:note.text().toString()}); } /** TAGS **/ for each(var subject in mods.m::subject) { newItem.tags.push(subject.text().toString()); } newItem.complete(); } }'); REPLACE INTO "translators" VALUES ('14763d24-8ba0-45df-8f52-b8d1108e7ac9', '2006-07-07 12:44:00', 2, 'Biblio/DC/FOAF/PRISM/VCard (RDF/XML)', 'Simon Kornblith', 'rdf', 'Scholar.configure("getCollections", true); Scholar.configure("dataMode", "rdf"); Scholar.addOption("exportNotes", true); Scholar.addOption("exportFileData", false);', 'function generateSeeAlso(resource, seeAlso) { for(var i in seeAlso) { if(itemResources[seeAlso[i]]) { Scholar.RDF.addStatement(resource, n.dc+"relation", itemResources[seeAlso[i]], false); } } } function generateTags(resource, tags) { for(var j in tags) { Scholar.RDF.addStatement(resource, n.dc+"subject", tags[j], true); } } function generateCollection(collection) { var collectionResource = "#collection:"+collection.id; Scholar.RDF.addStatement(collectionResource, rdf+"type", n.bib+"Collection", false); Scholar.RDF.addStatement(collectionResource, n.dc+"title", collection.name, true); for each(var child in collection.children) { // add child list items if(child.type == "collection") { Scholar.RDF.addStatement(collectionResource, n.dcterms+"hasPart", "#collection:"+child.id, false); // do recursive processing of collections generateCollection(child); } else if(itemResources[child.id]) { Scholar.RDF.addStatement(collectionResource, n.dcterms+"hasPart", itemResources[child.id], false); } } } function handleAttachment(attachmentResource, attachment) { Scholar.RDF.addStatement(attachmentResource, rdf+"type", n.fs+"Attachment", false); if(attachment.path) { Scholar.RDF.addStatement(attachmentResource, rdf+"resource", attachment.path, false); } if(attachment.url) { // add url as identifier var term = Scholar.RDF.newResource(); // set term type Scholar.RDF.addStatement(term, rdf+"type", n.dcterms+"URI", false); // set url value Scholar.RDF.addStatement(term, rdf+"value", attachment.url, true); // add relationship to resource Scholar.RDF.addStatement(attachmentResource, n.dc+"identifier", term, false); } // set mime type value Scholar.RDF.addStatement(attachmentResource, n.link+"type", attachment.mimeType, true); // set charset value if(attachment.charset) { Scholar.RDF.addStatement(attachmentResource, n.link+"charset", attachment.charset, true); } // add title Scholar.RDF.addStatement(attachmentResource, n.dc+"title", attachment.title, true); // Add see also info to RDF generateSeeAlso(attachmentResource, attachment.seeAlso); generateTags(attachmentResource, attachment.tags); } function doExport() { rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; n = { bib:"http://purl.org/net/biblio#", dc:"http://purl.org/dc/elements/1.1/", dcterms:"http://purl.org/dc/terms/", prism:"http://prismstandard.org/namespaces/1.2/basic/", foaf:"http://xmlns.com/foaf/0.1/", vcard:"http://nwalsh.com/rdf/vCard#", link:"http://purl.org/rss/1.0/modules/link/", fs:"http://chnm.gmu.edu/firefoxscholar/rdf#" }; // add namespaces for(var i in n) { Scholar.RDF.addNamespace(i, n[i]); } // leave as global itemResources = new Array(); // keep track of resources already assigned (in case two book items have the // same ISBN, or something like that) var usedResources = new Array(); var items = new Array(); // first, map each ID to a resource while(item = Scholar.nextItem()) { items.push(item); if(item.ISBN && !usedResources["urn:isbn:"+item.ISBN]) { itemResources[item.itemID] = "urn:isbn:"+item.ISBN; usedResources[itemResources[item.itemID]] = true; } else if(item.itemType != "attachment" && item.url && !usedResources[item.url]) { itemResources[item.itemID] = item.url; usedResources[itemResources[item.itemID]] = true; } else { // just specify a node ID itemResources[item.itemID] = "#item:"+item.itemID; } for(var j in item.notes) { itemResources[item.notes[j].itemID] = "#item:"+item.notes[j].itemID; } for each(var attachment in item.attachments) { // just specify a node ID itemResources[attachment.itemID] = "#item:"+attachment.itemID; } } for each(item in items) { // these items are global resource = itemResources[item.itemID]; container = null; containerElement = null; section = null; /** CORE FIELDS **/ // title if(item.title) { Scholar.RDF.addStatement(resource, n.dc+"title", item.title, true); } // type var type = null; if(item.itemType == "book") { type = "Book"; } else if (item.itemType == "bookSection") { type = "BookSection"; container = "Book"; } else if(item.itemType == "journalArticle") { type = "Article"; container = "Journal"; } else if(item.itemType == "magazineArticle") { type = "Article"; container = "Periodical"; } else if(item.itemType == "newspaperArticle") { type = "Article"; container = "Newspaper"; } else if(item.itemType == "thesis") { type = "Thesis"; } else if(item.itemType == "letter") { type = "Letter"; } else if(item.itemType == "manuscript") { type = "Manuscript"; } else if(item.itemType == "interview") { type = "Interview"; } else if(item.itemType == "film") { type = "MotionPicture"; } else if(item.itemType == "artwork") { type = "Illustration"; } else if(item.itemType == "website") { type = "Document"; } else if(item.itemType == "note") { type = "Memo"; if(!Scholar.getOption("exportNotes")) { continue; } } else if(item.itemType == "attachment") { handleAttachment(resource, item); continue; } if(type) { Scholar.RDF.addStatement(resource, rdf+"type", n.bib+type, false); } // authors/editors/contributors var creatorContainers = new Object(); for(var j in item.creators) { var creator = Scholar.RDF.newResource(); Scholar.RDF.addStatement(creator, rdf+"type", n.foaf+"Person", false); // gee. an entire vocabulary for describing people, and these aren''t even // standardized in it. oh well. using them anyway. Scholar.RDF.addStatement(creator, n.foaf+"surname", item.creators[j].lastName, true); Scholar.RDF.addStatement(creator, n.foaf+"givenname", item.creators[j].firstName, true); // in addition, these tags are not yet in Biblio, but Bruce D''Arcus // says they will be. if(item.creators[j].creatorType == "author") { var cTag = "authors"; } else if(item.creators[j].creatorType == "editor") { var cTag = "editors"; } else { var cTag = "contributors"; } if(!creatorContainers[cTag]) { var creatorResource = Scholar.RDF.newResource(); // create new seq for author type creatorContainers[cTag] = Scholar.RDF.newContainer("seq", creatorResource); // attach container to resource Scholar.RDF.addStatement(resource, n.bib+cTag, creatorResource, false); } Scholar.RDF.addContainerElement(creatorContainers[cTag], creator, false); } /** FIELDS ON NEARLY EVERYTHING BUT NOT A PART OF THE CORE **/ // source if(item.source) { Scholar.RDF.addStatement(resource, n.dc+"source", item.source, true); } // url if(item.url) { // add url as identifier var term = Scholar.RDF.newResource(); // set term type Scholar.RDF.addStatement(term, rdf+"type", n.dcterms+"URI", false); // set url value Scholar.RDF.addStatement(term, rdf+"value", attachment.url, true); // add relationship to resource Scholar.RDF.addStatement(resource, n.dc+"identifier", term, false); } // accessionNumber as generic ID if(item.accessionNumber) { Scholar.RDF.addStatement(resource, n.dc+"identifier", item.accessionNumber, true); } // rights if(item.rights) { Scholar.RDF.addStatement(resource, n.dc+"rights", item.rights, true); } /** SUPPLEMENTAL FIELDS **/ // use section to set up another container element if(item.section) { section = Scholar.RDF.newResource(); // leave as global // set section type Scholar.RDF.addStatement(section, rdf+"type", n.bib+"Part", false); // set section title Scholar.RDF.addStatement(section, n.dc+"title", item.section, true); // add relationship to resource Scholar.RDF.addStatement(resource, n.dc+"isPartOf", section, false); } // generate container if(container) { if(item.ISSN && !Scholar.RDF.getArcsIn("urn:issn:"+item.ISSN)) { // use ISSN as container URI if no other item is containerElement = "urn:issn:"+item.ISSN } else { containerElement = Scholar.RDF.newResource(); } // attach container to section (if exists) or resource Scholar.RDF.addStatement((section ? section : resource), n.dcterms+"isPartOf", containerElement, false); // add container type Scholar.RDF.addStatement(containerElement, rdf+"type", n.bib+container, false); } // ISSN if(item.ISSN) { Scholar.RDF.addStatement((containerElement ? containerElement : resource), n.dc+"identifier", "ISSN "+item.ISSN, true); } // ISBN if(item.ISBN) { Scholar.RDF.addStatement((containerElement ? containerElement : resource), n.dc+"identifier", "ISBN "+item.ISBN, true); } // DOI if(item.DOI) { Scholar.RDF.addStatement((containerElement ? containerElement : resource), n.dc+"identifier", "DOI "+item.DOI, true); } // publication gets linked to container via isPartOf if(item.publicationTitle) { Scholar.RDF.addStatement((containerElement ? containerElement : resource), n.dc+"title", item.publicationTitle, true); } // series also linked in if(item.seriesTitle) { var series = Scholar.RDF.newResource(); // set series type Scholar.RDF.addStatement(series, rdf+"type", n.bib+"Series", false); // set series title Scholar.RDF.addStatement(series, n.dc+"title", item.seriesTitle, true); // add relationship to resource Scholar.RDF.addStatement((containerElement ? containerElement : resource), n.dcterms+"isPartOf", series, false); } // volume if(item.volume) { Scholar.RDF.addStatement((containerElement ? containerElement : resource), n.prism+"volume", item.volume, true); } // number if(item.issue) { Scholar.RDF.addStatement((containerElement ? containerElement : resource), n.prism+"number", item.issue, true); } // edition if(item.edition) { Scholar.RDF.addStatement(resource, n.prism+"edition", item.edition, true); } // publisher/distributor and place if(item.publisher || item.distributor || item.place) { var organization = Scholar.RDF.newResource(); // set organization type Scholar.RDF.addStatement(organization, rdf+"type", n.foaf+"Organization", false); // add relationship to resource Scholar.RDF.addStatement(resource, n.dc+"publisher", organization, false); // add publisher/distributor if(item.publisher) { Scholar.RDF.addStatement(organization, n.foaf+"name", item.publisher, true); } else if(item.distributor) { Scholar.RDF.addStatement(organization, n.foaf+"name", item.distributor, true); } // add place if(item.place) { var address = Scholar.RDF.newResource(); // set address type Scholar.RDF.addStatement(address, rdf+"type", n.vcard+"Address", false); // set address locality Scholar.RDF.addStatement(address, n.vcard+"locality", item.place, true); // add relationship to organization Scholar.RDF.addStatement(organization, n.vcard+"adr", address, false); } } // date/year if(item.date) { Scholar.RDF.addStatement(resource, n.dc+"date", item.date, true); } if(item.accessDate) { // use date submitted for access date? Scholar.RDF.addStatement(resource, n.dcterms+"dateSubmitted", item.accessDate, true); } // callNumber if(item.callNumber) { var term = Scholar.RDF.newResource(); // set term type Scholar.RDF.addStatement(term, rdf+"type", n.dcterms+"LCC", false); // set callNumber value Scholar.RDF.addStatement(term, rdf+"value", item.callNumber, true); // add relationship to resource Scholar.RDF.addStatement(resource, n.dc+"subject", term, false); } // archiveLocation if(item.archiveLocation) { Scholar.RDF.addStatement(resource, n.dc+"coverage", item.archiveLocation, true); } // type (not itemType) if(item.type) { Scholar.RDF.addStatement(resource, n.dc+"type", item.type, true); } else if(item.thesisType) { Scholar.RDF.addStatement(resource, n.dc+"type", item.thesisType, true); } // THIS IS NOT YET IN THE BIBLIO NAMESPACE, BUT BRUCE D''ARCUS HAS SAID // IT WILL BE SOON if(item.pages) { Scholar.RDF.addStatement(resource, n.bib+"pages", item.pages, true); } // journalAbbreviation if(item.journalAbbreviation) { Scholar.RDF.addStatement((containerElement ? containerElement : resource), n.dcterms+"alternative", item.journalAbbreviation, true); } /** NOTES **/ if(Scholar.getOption("exportNotes")) { for(var j in item.notes) { var noteResource = itemResources[item.notes[j].itemID]; // add note tag Scholar.RDF.addStatement(noteResource, rdf+"type", n.bib+"Memo", false); // add note value Scholar.RDF.addStatement(noteResource, rdf+"value", item.notes[j].note, true); // add relationship between resource and note Scholar.RDF.addStatement(resource, n.dcterms+"isReferencedBy", noteResource, false); // Add see also info to RDF generateSeeAlso(noteResource, item.notes[j].seeAlso); generateTags(noteResource, item.notes[j].tags); } if(item.note) { Scholar.RDF.addStatement(resource, rdf+"value", item.note, true); } } /** FILES **/ for each(var attachment in item.attachments) { var attachmentResource = itemResources[attachment.itemID]; Scholar.RDF.addStatement(resource, n.link+"link", attachmentResource, false); handleAttachment(attachmentResource, attachment); } /** SEE ALSO AND TAGS **/ generateSeeAlso(resource, item.seeAlso); generateTags(resource, item.tags); } /** RDF COLLECTION STRUCTURE **/ var collection; while(collection = Scholar.nextCollection()) { generateCollection(collection); } }'); REPLACE INTO "translators" VALUES ('6e372642-ed9d-4934-b5d1-c11ac758ebb7', '2006-07-05 23:40:00', 2, 'Unqualified Dublin Core (RDF/XML)', 'Simon Kornblith', 'rdf', 'Scholar.configure("dataMode", "rdf");', 'function doExport() { var dc = "http://purl.org/dc/elements/1.1/"; Scholar.RDF.addNamespace("dc", dc); var item; while(item = Scholar.nextItem()) { if(item.itemType == "note") { continue; } var resource; if(item.ISBN) { resource = "urn:isbn:"+item.ISBN; } else if(item.url) { resource = item.url; } else { // just specify a node ID resource = Scholar.RDF.newResource(); } /** CORE FIELDS **/ // title if(item.title) { Scholar.RDF.addStatement(resource, dc+"title", item.title, true); } // type Scholar.RDF.addStatement(resource, dc+"type", item.itemType, true); // creators for(var j in item.creators) { // put creators in lastName, firstName format (although DC doesn''t specify) var creator = item.creators[j].lastName; if(item.creators[j].firstName) { creator += ", "+item.creators[j].firstName; } if(item.creators[j].creatorType == "author") { Scholar.RDF.addStatement(resource, dc+"creator", creator, true); } else { Scholar.RDF.addStatement(resource, dc+"contributor", creator, true); } } /** FIELDS ON NEARLY EVERYTHING BUT NOT A PART OF THE CORE **/ // source if(item.source) { Scholar.RDF.addStatement(resource, dc+"source", item.source, true); } // accessionNumber as generic ID if(item.accessionNumber) { Scholar.RDF.addStatement(resource, dc+"identifier", item.accessionNumber, true); } // rights if(item.rights) { Scholar.RDF.addStatement(resource, dc+"rights", item.rights, true); } /** SUPPLEMENTAL FIELDS **/ // TODO - create text citation and OpenURL citation to handle volume, number, pages, issue, place // publisher/distributor if(item.publisher) { Scholar.RDF.addStatement(resource, dc+"publisher", item.publisher, true); } else if(item.distributor) { Scholar.RDF.addStatement(resource, dc+"publisher", item.distributor, true); } // date/year if(item.date) { Scholar.RDF.addStatement(resource, dc+"date", item.date, true); } // ISBN/ISSN/DOI if(item.ISBN) { Scholar.RDF.addStatement(resource, dc+"identifier", "ISBN "+item.ISBN, true); } if(item.ISSN) { Scholar.RDF.addStatement(resource, dc+"identifier", "ISSN "+item.ISSN, true); } if(item.DOI) { Scholar.RDF.addStatement(resource, dc+"identifier", "DOI "+item.DOI, true); } // callNumber if(item.callNumber) { Scholar.RDF.addStatement(resource, dc+"identifier", item.callNumber, true); } // archiveLocation if(item.archiveLocation) { Scholar.RDF.addStatement(resource, dc+"coverage", item.archiveLocation, true); } } }'); REPLACE INTO "translators" VALUES ('5e3ad958-ac79-463d-812b-a86a9235c28f', '2006-07-15 17:09:00', 1, 'RDF', 'Simon Kornblith', 'rdf', 'Scholar.configure("dataMode", "rdf"); function detectImport() { // unfortunately, Mozilla will let you create a data source from any type // of XML, so we need to make sure there are actually nodes var nodes = Scholar.RDF.getAllResources(); if(nodes) { return true; } }', '// gets the first result set for a property that can be encoded in multiple // ontologies function getFirstResults(node, properties, onlyOneString) { for(var i=0; i this.indicatorLength) { indicator = indicator.substr(0, this.indicatorLength); } else if(indicator.length != this.indicatorLength) { indicator = Scholar.Utilities.lpad(indicator, " ", this.indicatorLength); } // add terminator value = indicator+value+fieldTerminator; // add field to directory if(!this.directory[field]) { this.directory[field] = new Array(); } this.directory[field].push([this.content.length, value.length]); // add field to record this.content += value; } // get all fields with a certain field number record.prototype.getField = function(field) { var fields = new Array(); // make sure fields exist if(!this.directory[field]) { return fields; } // get fields for(var i in this.directory[field]) { var location = this.directory[field][i]; // add to array fields.push([this.content.substr(location[0], this.indicatorLength), this.content.substr(location[0]+this.indicatorLength, location[1]-this.indicatorLength-1)]); } return fields; } // get subfields from a field record.prototype.getFieldSubfields = function(tag) { // returns a two-dimensional array of values var fields = this.getField(tag); var returnFields = new Array(); for(var i in fields) { returnFields[i] = new Object(); var subfields = fields[i][1].split(subfieldDelimiter); if (subfields.length == 1) { returnFields[i]["?"] = fields[i][1]; } else { for(var j in subfields) { if(subfields[j]) { returnFields[i][subfields[j].substr(0, this.subfieldCodeLength-1)] = subfields[j].substr(this.subfieldCodeLength-1); } } } } return returnFields; } // add field to DB record.prototype._associateDBField = function(item, fieldNo, part, fieldName, execMe, arg1, arg2) { var field = this.getFieldSubfields(fieldNo); Scholar.Utilities.debug(''found ''+field.length+'' matches for ''+fieldNo+part); if(field) { for(var i in field) { var value = false; for(var j=0; j 1) { records[0] = holdOver + records[0]; holdOver = records.pop(); // skip last record, since it''s not done for(var i in records) { var newItem = new Scholar.Item(); // create new record var rec = new record(); rec.importBinary(records[i]); rec.translate(newItem); newItem.complete(); } } else { holdOver += text; } } }'); REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '2006-08-12 19:22:00', 'APA', ' '); REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.csl', '2006-08-12 19:22:00', 'Chicago (Footnote)', ' ');