Skip to content

Commit

Permalink
v0.9.2
Browse files Browse the repository at this point in the history
- Expansion of search for the title in method `meico.mei.Mei.getTitle()`, so it supports MEI 3.0 (`workDesc`) and MEI 4.0+ (`workList`).
  • Loading branch information
axelberndt committed Jun 19, 2024
1 parent f1cb413 commit 44ff230
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
12 changes: 9 additions & 3 deletions src/meico/mei/Mei.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 44ff230

Please sign in to comment.