diff --git a/translators/NCBI PubMed.js b/translators/NCBI PubMed.js index 5dd0c2e6e..80bfb78b6 100644 --- a/translators/NCBI PubMed.js +++ b/translators/NCBI PubMed.js @@ -4,12 +4,13 @@ "label":"NCBI PubMed", "creator":"Simon Kornblith, Michael Berkowitz, Avram Lyon, and Rintze Zelle", "target":"https?://[^/]*(www|preview)\\.ncbi\\.nlm\\.nih\\.gov[^/]*/(pubmed|sites/pubmed|sites/entrez|entrez/query\\.fcgi\\?.*db=PubMed)", - "minVersion":"2.1b1", + "minVersion":"2.1.9", "maxVersion":"", "priority":100, + "browserSupport":"gcs", "configOptions":{"dataMode":"block"}, "inRepository":true, - "lastUpdated":"2011-04-25 18:05:00" + "lastUpdated":"2011-07-01 04:22:03" } function detectWeb(doc, url) { @@ -91,9 +92,6 @@ function detectImport() { } function doImportFromText(text) { - // Remove xml parse instruction and doctype - text = text.replace(/]*>/, "").replace(/<\?xml[^>]*\?>/, ""); - if (!text.substr(0,1000).match(//)) { // Pubmed data in the wild, perhaps copied from the web site's search results, // can be missing the root tag. Let's add a pair! @@ -101,28 +99,30 @@ function doImportFromText(text) { text = "" + text + ""; } - var xml = new XML(text); + // parse XML with DOMParser + var parser = new DOMParser(); + var doc = parser.parseFromString(text, "text/xml"); - for(var i=0; i]+)?[^>]*>/g, "$1\n") - ); - - newItem.DOI = xml.PubmedArticle[i].PubmedData.ArticleIdList.ArticleId.(@IdType == "doi" ).text().toString(); - newItem.publicationTitle = Zotero.Utilities.capitalizeTitle(newItem.publicationTitle); newItem.complete(); } } @@ -238,17 +250,17 @@ function doWeb(doc, url) { items[uid.value] = article.textContent; } - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - for(var i in items) { - ids.push(i); - } - - lookupPMIDs(ids); + Zotero.selectItems(items, function(items) { + if(!items) { + return true; + } + + for(var i in items) { + ids.push(i); + } + + lookupPMIDs(ids); + }); } else { ids.push(uid.value); lookupPMIDs(ids, doc); @@ -293,3 +305,55 @@ function doSearch(item) { // pmid was defined earlier in detectSearch lookupPMIDs([getPMID(item.contextObject)]); } + + +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "http://www.ncbi.nlm.nih.gov/pubmed/20729678", + "items": [ + { + "itemType": "journalArticle", + "creators": [ + { + "lastName": "Coar", + "firstName": "Jaekea T" + }, + { + "lastName": "Sewell", + "firstName": "Jeanne P" + } + ], + "notes": [], + "tags": [ + "Bibliography as Topic", + "Database Management Systems", + "Humans" + ], + "seeAlso": [], + "attachments": [], + "url": "http://www.ncbi.nlm.nih.gov/pubmed/20729678", + "extra": "PMID: 20729678", + "title": "Zotero: harnessing the power of a personal bibliographic manager", + "pages": "205-207", + "ISSN": "1538-9855", + "journalAbbreviation": "Nurse Educ", + "publicationTitle": "Nurse Educator", + "volume": "35", + "issue": "5", + "date": "2010 Sep-Oct", + "abstractNote": "Zotero is a powerful free personal bibliographic manager (PBM) for writers. Use of a PBM allows the writer to focus on content, rather than the tedious details of formatting citations and references. Zotero 2.0 (http://www.zotero.org) has new features including the ability to synchronize citations with the off-site Zotero server and the ability to collaborate and share with others. An overview on how to use the software and discussion about the strengths and limitations are included.\u000a", + "DOI": "10.1097/NNE.0b013e3181ed81e4", + "libraryCatalog": "NCBI PubMed", + "shortTitle": "Zotero" + } + ] + }, + { + "type": "web", + "url": "http://www.ncbi.nlm.nih.gov/pubmed?term=zotero", + "items": "multiple" + } +] +/** END TEST CASES **/ \ No newline at end of file