Skip to content

Commit

Permalink
*8185* allow eLocation page ranges in PubMed export
Browse files Browse the repository at this point in the history
  • Loading branch information
jnugent committed Apr 3, 2013
1 parent f19d1bf commit 3f2cf9b
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions plugins/importexport/pubmed/PubMedExportDom.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class PubMedExportDom {
* Build article XML using DOM elements
* @param $args Parameters to the plugin
*
* The DOM for this XML was developed according to the NLM
* Standard Publisher Data Format:
* The DOM for this XML was developed according to the NLM
* Standard Publisher Data Format:
* http://www.ncbi.nlm.nih.gov/entrez/query/static/spec.html
*/
*/

function &generatePubMedDom() {
// create the output XML document in DOM with a root node
Expand Down Expand Up @@ -85,7 +85,7 @@ function &generateArticleDom(&$doc, &$journal, &$issue, &$section, &$article) {
// XMLCustomWriter::createChildWithText($doc, $root, 'Replaces', '');

/* --- ArticleTitle / VernacularTitle --- */
// there is some ambiguity between whether to use
// there is some ambiguity between whether to use
// article->getlanguage or journal->getlocale
// PubMed requires english titles for ArticleTitle
$language = $article->getLanguage();
Expand All @@ -102,24 +102,27 @@ function &generateArticleDom(&$doc, &$journal, &$issue, &$section, &$article) {
$pages = $article->getPages();
if (preg_match("/([0-9]+)\s*-\s*([0-9]+)/i", $pages, $matches)) {
// simple pagination (eg. "pp. 3- 8")
XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $matches[1]);
XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $matches[1]);
XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $matches[2]);
} elseif (preg_match("/(e[0-9]+)\s*-\s*(e[0-9]+)/i", $pages, $matches)) { // e9 - e14, treated as page ranges
XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $matches[1]);
XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $matches[2]);
}elseif (preg_match("/(e[0-9]+)/i", $pages, $matches)) {
// elocation-id (eg. "e12")
} elseif (preg_match("/(e[0-9]+)/i", $pages, $matches)) {
// single elocation-id (eg. "e12")
XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $matches[1]);
XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $matches[1]);
XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $matches[1]);
} else {
// we need to insert something, so use the best ID possible
XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $article->getBestArticleId($journal));
XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $article->getBestArticleId($journal));
XMLCustomWriter::createChildWithText($doc, $root, 'FirstPage', $article->getBestArticleId($journal));
XMLCustomWriter::createChildWithText($doc, $root, 'LastPage', $article->getBestArticleId($journal));
}

/* --- DOI --- */
if ($doi = $article->getDOI()) {
$doiNode =& XMLCustomWriter::createChildWithText($doc, $root, 'ELocationID', $doi, false);
XMLCustomWriter::setAttribute($doiNode, 'EIdType', 'doi');
}

/* --- Language --- */
XMLCustomWriter::createChildWithText($doc, $root, 'Language', strtoupper($article->getLanguage()), false);

Expand Down

0 comments on commit 3f2cf9b

Please sign in to comment.