Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#53 DOI text nodes are doubled up #54

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 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,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));
Expand Down Expand Up @@ -508,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