From 7ef77c50cd81eb0650ca2ddefb2dad8ba4d1de16 Mon Sep 17 00:00:00 2001 From: Brendan O'Connell Date: Wed, 10 Jul 2024 15:54:15 +0200 Subject: [PATCH] Fixed changelog, added logic for EditionStatement, only exclude keywords from subject export --- CHANGELOG.md | 2 +- .../src/xml/onix3_project_muse.rs | 29 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a3d5045..fa8a6726 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed - - [609](https://github.com/thoth-pub/thoth/pull/609) - Update Project MUSE ONIX 3.0 export to reflect new specifications provided by Project MUSE. + - [538](https://github.com/thoth-pub/thoth/issues/538) - Update Project MUSE ONIX 3.0 export to reflect new specifications provided by Project MUSE. ## [[0.12.6]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.6) - 2024-06-17 ### Fixed diff --git a/thoth-export-server/src/xml/onix3_project_muse.rs b/thoth-export-server/src/xml/onix3_project_muse.rs index 93cd3570..432e5093 100644 --- a/thoth-export-server/src/xml/onix3_project_muse.rs +++ b/thoth-export-server/src/xml/onix3_project_muse.rs @@ -187,6 +187,29 @@ impl XmlElementBlock for Work { for contribution in &self.contributions { XmlElementBlock::::xml_element(contribution, w).ok(); } + if let Some(edition) = &self.edition { + if let Some(edition_statement) = match edition { + // Spell out commonest ordinals + 1 => Some("First edition.".to_string()), + 2 => Some("Second edition.".to_string()), + 3 => Some("Third edition.".to_string()), + _ => { + let suffix = match edition % 10 { + 1 if edition % 100 != 11 => "st", + 2 if edition % 100 != 12 => "nd", + 3 if edition % 100 != 13 => "rd", + _ => "th", + }; + Some(format!("{}{} edition.", edition, suffix)) + } + } { + write_element_block("EditionStatement", w, |w| { + w.write(XmlEvent::Characters(&edition_statement)) + .map_err(|e| e.into()) + })?; + } + } + for language in &self.languages { XmlElementBlock::::xml_element(language, w).ok(); } @@ -207,10 +230,8 @@ impl XmlElementBlock for Work { })?; } for subject in &self.subjects { - // According to spec, Project MUSE only accepts BIC and BISAC subject codes - if subject.subject_type == SubjectType::BIC - || subject.subject_type == SubjectType::BISAC - { + // Project MUSE can't process records containing keywords + if subject.subject_type != SubjectType::KEYWORD { write_element_block("Subject", w, |w| { XmlElement::::xml_element( &subject.subject_type,