Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions CrossrefExportDeployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class CrossrefExportDeployment
public const CROSSREF_XMLNS_AI = 'http://www.crossref.org/AccessIndicators.xsd';
public const CROSSREF_XMLNS_XML = 'http://www.w3.org/XML/1998/namespace';
public const CROSSREF_XMLNS_REL = 'http://www.crossref.org/relations.xsd';
public const CROSSREF_XMLNS_FR = 'http://www.crossref.org/fundref.xsd';

public Context $_context;

Expand Down Expand Up @@ -97,6 +98,14 @@ public function getXmlSchemaLocation(): string
return static::CROSSREF_XSI_SCHEMALOCATION;
}

/**
* Get the FundRef namespace URN
*/
public function getFundrefNamespace(): string
{
return static::CROSSREF_XMLNS_FR;
}

/**
* Get the JATS namespace URN
*/
Expand Down
87 changes: 86 additions & 1 deletion filter/ArticleCrossrefXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ public function createJournalArticleNode(DOMDocument $doc, Publication $publicat
// rel:program
$this->appendRelationships($doc, $journalArticleNode, $this->versionsDois);
} else {
// if no crossmark element is used, append ai:program here
// if no crossmark element is used, append program nodes here
// fr:program (FundRef)
$this->appendFundrefNode($doc, $journalArticleNode, $publication);
// ai:program (AccessIndicators) element, that contains the license URL
$this->appendProgramNode($doc, $journalArticleNode, $publication);
}
Expand Down Expand Up @@ -439,6 +441,86 @@ public function appendProgramNode(DOMDocument $doc, DOMElement $parentNode, Publ
}
}

/**
* Append fr:program (FundRef) node with funding information
*/
public function appendFundrefNode(DOMDocument $doc, DOMElement $parentNode, Publication $publication): void
{
/** @var CrossrefExportDeployment $deployment */
$deployment = $this->getDeployment();

$funders = $publication->getData('funders');

if (empty($funders)) {
return;
}

$locale = $publication->getData('locale');

$programNode = $doc->createElementNS($deployment->getFundrefNamespace(), 'fr:program');
$programNode->setAttribute('name', 'fundref');

foreach ($funders as $funder) {

$groupNode = $doc->createElementNS($deployment->getFundrefNamespace(), 'fr:assertion');
$groupNode->setAttribute('name', 'fundgroup');

$funderName = $funder->getLocalizedData('name', $locale);

$rorNode = null;
if (!empty($funder->ror)) {
$rorNode = $doc->createElementNS($deployment->getFundrefNamespace(), 'fr:assertion', $funder->ror);
$rorNode->setAttribute('name', 'ror');
}

if (!empty($funderName)) {
$funderNameNode = $doc->createElementNS($deployment->getFundrefNamespace(), 'fr:assertion', htmlspecialchars($funderName, ENT_COMPAT, 'UTF-8'));
$funderNameNode->setAttribute('name', 'funder_name');
if ($rorNode) {
$funderNameNode->appendChild($rorNode);
}
$groupNode->appendChild($funderNameNode);
} elseif ($rorNode) {
$groupNode->appendChild($rorNode);
Comment thread
ajnyga marked this conversation as resolved.
}

if (!empty($funder->grants)) {
foreach ($funder->grants as $grant) {

$awardNode = null;
if (!empty($grant['grantNumber'])) {
$awardNode = $doc->createElementNS($deployment->getFundrefNamespace(), 'fr:assertion', htmlspecialchars($grant['grantNumber'], ENT_COMPAT, 'UTF-8'));
$awardNode->setAttribute('name', 'award_number');
}

if (!empty($grant['grantDoi'])) {
$grantDoiNode = $doc->createElementNS($deployment->getFundrefNamespace(), 'fr:assertion', htmlspecialchars($grant['grantDoi'], ENT_COMPAT, 'UTF-8'));
$grantDoiNode->setAttribute('name', 'grant_doi');

if ($awardNode) {
$grantDoiNode->appendChild($awardNode);
}

$groupNode->appendChild($grantDoiNode);

} elseif ($awardNode) {
$groupNode->appendChild($awardNode);
}
}
Comment thread
ajnyga marked this conversation as resolved.
}

if ($groupNode->hasChildNodes()) {
$programNode->appendChild($groupNode);
}

}

if ($programNode->hasChildNodes()) {
$parentNode->appendChild($programNode);
}

}

/**
* Append the collection node 'collection property="crawler-based"' to the doi data node.
*/
Expand Down Expand Up @@ -715,6 +797,9 @@ public function appendCrossmarkNode(DOMDocument $doc, DOMElement $parentNode, ar
$customMetadataNode->appendChild($assertionFundingStatementNode);
}

// fr:program (FundRef)
$this->appendFundrefNode($doc, $customMetadataNode, $publication);

// ai:program (AccessIndicators) element, that contains the license URL
$this->appendProgramNode($doc, $customMetadataNode, $publication);

Expand Down
2 changes: 2 additions & 0 deletions filter/IssueCrossrefXmlFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public function createRootNode(DOMDocument $doc): DOMElement
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:jats', $deployment->getJATSNamespace());
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:ai', $deployment->getAINamespace());
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:rel', $deployment->getRelNamespace());
$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:fr', $deployment->getFundrefNamespace());

$rootNode->setAttribute('version', $deployment->getXmlSchemaVersion());
$rootNode->setAttribute('xsi:schemaLocation', $deployment->getNamespace() . ' ' . $deployment->getSchemaFilename());
return $rootNode;
Expand Down