Skip to content

Commit

Permalink
#53 DOI text nodes are doubled up
Browse files Browse the repository at this point in the history
  • Loading branch information
ewhanson committed Nov 13, 2024
1 parent 77e2a91 commit 4f2ca5b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions OAIMetadataFormat_JATS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -259,23 +259,23 @@ 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'
)
)
);
$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));

Expand All @@ -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'));
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4f2ca5b

Please sign in to comment.