diff --git a/filter/PreprintCrossrefXmlFilter.inc.php b/filter/PreprintCrossrefXmlFilter.inc.php index 403b2c9a87..9d911f1e31 100644 --- a/filter/PreprintCrossrefXmlFilter.inc.php +++ b/filter/PreprintCrossrefXmlFilter.inc.php @@ -243,9 +243,20 @@ public function createPostedContentNode($doc, $publication, $submission) $postedContentNode->appendChild($licenseNode); } - // DOI relations - if ($submission->getLatestPublication()->getDoi() && $submission->getLatestPublication()->getDoi() != $publication->getDoi()) { - $postedContentNode->appendChild($this->createRelationsDataNode($doc, $submission->getLatestPublication()->getDoi())); + // DOI relations: if this version has a vorDoi or different DOI than the current publication (ie. versions and DOI versioning exits), add a relation node + $parentDoi = $submission->getCurrentPublication()->getDoi() && $submission->getCurrentPublication()->getDoi() != $publication->getDoi() ? $submission->getCurrentPublication()->getDoi() : ''; + $vorDoi = $publication->getData('vorDoi') ? $publication->getData('vorDoi') : ''; + + if ($parentDoi || $vorDoi) { + $relationsDataNode = $doc->createElementNS($deployment->getRELNamespace(), 'rel:program'); + $relationsDataNode->setAttribute('name', 'relations'); + if ($parentDoi) { + $relationsDataNode->appendChild($this->createParentDoiNode($doc, $parentDoi)); + } + if ($vorDoi) { + $relationsDataNode->appendChild($this->createVorDoiNode($doc, $vorDoi)); + } + $postedContentNode->appendChild($relationsDataNode); } // DOI data @@ -298,27 +309,43 @@ public function createDOIDataNode($doc, $doi, $url) } /** - * Create and return the 'program' node for DOI relations. + * Create and return the parent DOI relation node. * * @param $doc DOMDocument * @param $parentDoi string * * @return DOMElement */ - public function createRelationsDataNode($doc, $parentDoi) + public function createParentDoiNode($doc, $parentDoi) { $deployment = $this->getDeployment(); - $relationsDataNode = $doc->createElementNS($deployment->getRELNamespace(), 'rel:program'); - $relationsDataNode->setAttribute('name', 'relations'); - - $relatedItemNode = $doc->createElementNS($deployment->getRELNamespace(), 'rel:related_item'); - $intraWorkRelationNode = $doc->createElementNS($deployment->getRELNamespace(), 'rel:intra_work_relation', htmlspecialchars($parentDoi, ENT_COMPAT, 'UTF-8')); + $parentDoiNode = $doc->createElementNS($deployment->getRELNamespace(), 'rel:related_item'); + $intraWorkRelationNode = $doc->createElementNS($deployment->getRELNamespace(), 'rel:intra_work_relation', htmlspecialchars($parentDoi, ENT_COMPAT, 'UTF-8')); $intraWorkRelationNode->setAttribute('relationship-type', 'isVersionOf'); $intraWorkRelationNode->setAttribute('identifier-type', 'doi'); - $relatedItemNode->appendChild($intraWorkRelationNode); - $relationsDataNode->appendChild($relatedItemNode); + $parentDoiNode->appendChild($intraWorkRelationNode); + + return $parentDoiNode; + } + + /** + * Create and return the VOR DOI relation node. + * + * @param $doc DOMDocument + * @param $vorDoi string + * + * @return DOMElement + */ + public function createVorDoiNode($doc, $vorDoi) + { + $deployment = $this->getDeployment(); + $vorDoiNode = $doc->createElementNS($deployment->getRELNamespace(), 'rel:related_item'); + $intraWorkRelationNode = $doc->createElementNS($deployment->getRELNamespace(), 'rel:intra_work_relation', htmlspecialchars($vorDoi, ENT_COMPAT, 'UTF-8')); + $intraWorkRelationNode->setAttribute('relationship-type', 'isPreprintOf'); + $intraWorkRelationNode->setAttribute('identifier-type', 'doi'); + $vorDoiNode->appendChild($intraWorkRelationNode); - return $relationsDataNode; + return $vorDoiNode; } /**