From fe41bca5a87808d4c2f1fa1564a8410651e6ca57 Mon Sep 17 00:00:00 2001 From: Erik Hanson Date: Wed, 13 Nov 2024 09:49:36 -0800 Subject: [PATCH 1/2] pkp/oaiJats#53 DOI text nodes are doubled up --- OAIMetadataFormat_JATS.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OAIMetadataFormat_JATS.php b/OAIMetadataFormat_JATS.php index 8fdbfd8..d0ab2cb 100644 --- a/OAIMetadataFormat_JATS.php +++ b/OAIMetadataFormat_JATS.php @@ -365,8 +365,10 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) { // Store the DOI if ($doi = trim($article->getStoredPubId('doi'))) { $match = $xpath->query("//article/front/article-meta/article-id[@pub-id-type='doi']"); - if ($match->length) $match->item(0)->appendChild($doc->createTextNode($doi)); - else { + if ($match->length) { + $originalDoiNode = $match->item(0)->firstChild; + $match->item(0)->replaceChild($doc->createTextNode($doi), $originalDoiNode); + } else { $articleIdNode = $this->_addChildInOrder($articleMetaNode, $doc->createElement('article-id')); $articleIdNode->setAttribute('pub-id-type', 'doi'); $articleIdNode->appendChild($doc->createTextNode($doi)); From cafed2ba580ddf1f91dc51ee0a4843998b40453f Mon Sep 17 00:00:00 2001 From: Erik Hanson Date: Wed, 13 Nov 2024 09:49:51 -0800 Subject: [PATCH 2/2] pkp/oaiJats#53 DOI text nodes are doubled up --- OAIMetadataFormat_JATS.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/OAIMetadataFormat_JATS.php b/OAIMetadataFormat_JATS.php index d0ab2cb..fc36a3a 100644 --- a/OAIMetadataFormat_JATS.php +++ b/OAIMetadataFormat_JATS.php @@ -53,7 +53,7 @@ protected function _findJats($record) { ->filterByFileStages([SubmissionFile::SUBMISSION_FILE_PRODUCTION_READY]) ->filterBySubmissionIds([$article->getId()]) ->getMany(); - + foreach ($layoutFiles as $layoutFile) { if ($this->_isCandidateFile($layoutFile)) $candidateFiles[] = $layoutFile; } @@ -259,12 +259,12 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) { while ($titleGroupNode->hasChildNodes()) $titleGroupNode->removeChild($titleGroupNode->firstChild); $titleNode = $titleGroupNode->appendChild($doc->createElement('article-title')); $titleNode->setAttribute('xml:lang', substr($article->getLocale(),0,2)); - + $articleTitleHtml = $doc->createDocumentFragment(); $articleTitleHtml->appendXML( $this->mapHtmlTagsForTitle( $article->getCurrentPublication()->getLocalizedTitle( - $article->getLocale(), + $article->getLocale(), 'html' ) ) @@ -272,10 +272,10 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) { $titleNode->appendChild($articleTitleHtml); if (!empty($subtitle = $article->getCurrentPublication()->getLocalizedSubTitle($article->getLocale(), 'html'))) { - + $subtitleHtml = $doc->createDocumentFragment(); $subtitleHtml->appendXML($this->mapHtmlTagsForTitle($subtitle)); - + $subtitleNode = $titleGroupNode->appendChild($doc->createElement('subtitle')); $subtitleNode->setAttribute('xml:lang', substr($article->getLocale(),0,2)); @@ -285,11 +285,11 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) { if ($locale == $article->getLocale()) { continue; } - + if ( trim($title = $this->mapHtmlTagsForTitle($title)) === '' ) { continue; } - + $transTitleGroupNode = $titleGroupNode->appendChild($doc->createElement('trans-title-group')); $transTitleGroupNode->setAttribute('xml:lang', substr($locale,0,2)); $titleNode = $transTitleGroupNode->appendChild($doc->createElement('trans-title')); @@ -365,10 +365,10 @@ protected function _mungeMetadata($doc, $journal, $article, $section, $issue) { // Store the DOI if ($doi = trim($article->getStoredPubId('doi'))) { $match = $xpath->query("//article/front/article-meta/article-id[@pub-id-type='doi']"); - if ($match->length) { - $originalDoiNode = $match->item(0)->firstChild; - $match->item(0)->replaceChild($doc->createTextNode($doi), $originalDoiNode); - } else { + if ($match->length) { + $originalDoiNode = $match->item(0)->firstChild; + $match->item(0)->replaceChild($doc->createTextNode($doi), $originalDoiNode); + } else { $articleIdNode = $this->_addChildInOrder($articleMetaNode, $doc->createElement('article-id')); $articleIdNode->setAttribute('pub-id-type', 'doi'); $articleIdNode->appendChild($doc->createTextNode($doi)); @@ -510,8 +510,8 @@ protected function _isCandidateFile($submissionFile) { /** * Map the specific HTML tags in title/ sub title for JATS schema compability * @see https://jats.nlm.nih.gov/publishing/0.4/xsd/JATS-journalpublishing0.xsd - * - * @param string $htmlTitle The submission title/sub title as in HTML + * + * @param string $htmlTitle The submission title/sub title as in HTML * @return string */ public function mapHtmlTagsForTitle(string $htmlTitle): string