From 44ff23008e99b466a8353003e25263f4d8446b3b Mon Sep 17 00:00:00 2001 From: Axel Berndt Date: Wed, 19 Jun 2024 15:59:06 +0200 Subject: [PATCH] v0.9.2 - Expansion of search for the title in method `meico.mei.Mei.getTitle()`, so it supports MEI 3.0 (`workDesc`) and MEI 4.0+ (`workList`). --- history.md | 4 ++++ src/meico/mei/Mei.java | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/history.md b/history.md index c5e3b2de..b9a17e69 100644 --- a/history.md +++ b/history.md @@ -1,6 +1,10 @@ ### Version History +#### v0.9.2 +- Expansion of search for the title in method `meico.mei.Mei.getTitle()`, so it supports MEI 3.0 (`workDesc`) and MEI 4.0+ (`workList`). + + #### v0.9.1 - Some minor preparations in class `meico.mei.Mei2MusicXmlConverter` for MEI to MusicXML conversion. diff --git a/src/meico/mei/Mei.java b/src/meico/mei/Mei.java index 37194134..5e173e4e 100644 --- a/src/meico/mei/Mei.java +++ b/src/meico/mei/Mei.java @@ -142,18 +142,24 @@ public Element getMeiHead() { public String getTitle() { Element title; - try { // try to read the title from mei/meiHead/workDesc/work/titleStmt/title + try { // try to read the title from mei/meiHead/fileDesc/titleStmt/title title = Helper.getFirstChildElement("fileDesc", this.getMeiHead()); title = Helper.getFirstChildElement("titleStmt", title); title = Helper.getFirstChildElement("title", title); } catch (NullPointerException ex1) { // if that does not exist - try { // try to get the title from mei/meiHead/fileDesc/titleStmt/title + try { // try to get the title from MEI 3.0 mei/meiHead/workDesc/work/titleStmt/title title = Helper.getFirstChildElement("workDesc", this.getMeiHead()); title = Helper.getFirstChildElement("work", title); title = Helper.getFirstChildElement("titleStmt", title); title = Helper.getFirstChildElement("title", title); } catch (NullPointerException ex2) { // if that does not exist - return (this.getFile() == null) ? "" : Helper.getFilenameWithoutExtension(this.getFile().getName()); // return the filename without extension or (if that does not exist either) return empty string + try { // try to get the title from MEI 4.0+ mei/meiHead/workList/work/title + title = Helper.getFirstChildElement("workList", this.getMeiHead()); + title = Helper.getFirstChildElement("work", title); + title = Helper.getFirstChildElement("title", title); + } catch (NullPointerException ex3) { + return (this.getFile() == null) ? "" : Helper.getFilenameWithoutExtension(this.getFile().getName()); // return the filename without extension or (if that does not exist either) return empty string + } } } return (title != null) ? title.getValue() : ((this.getFile() == null) ? "" : Helper.getFilenameWithoutExtension(this.getFile().getName())); // return the title string