From 15328e6aae10486b259f5de86d51c792a076873e Mon Sep 17 00:00:00 2001 From: kukymbr <28160439+kukymbr@users.noreply.github.com> Date: Sat, 11 May 2024 00:14:01 +0300 Subject: [PATCH] Bible book name caption (#654) * bible: parse bible book name from the caption XML node * bible book: fix bsname parsing * bible book: fix book name in caption parsing * fix the go syntax --- .../java/org/quelea/data/bible/BibleBook.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Quelea/src/main/java/org/quelea/data/bible/BibleBook.java b/Quelea/src/main/java/org/quelea/data/bible/BibleBook.java index 0519a60bc..11d770a0f 100644 --- a/Quelea/src/main/java/org/quelea/data/bible/BibleBook.java +++ b/Quelea/src/main/java/org/quelea/data/bible/BibleBook.java @@ -168,14 +168,9 @@ public static BibleBook parseXML(Node node, int defaultBookNum, String defaultBo } else if (node.getAttributes().getNamedItem("osisID") != null) { ret.bookName = node.getAttributes().getNamedItem("osisID").getNodeValue(); } else { - ret.bookName = defaultBookName; - } - - if (node.getAttributes().getNamedItem("bsname") != null) { - ret.bsname = node.getAttributes().getNamedItem("bsname").getNodeValue(); - } else { - ret.bsname = ret.bookName; + ret.bookName = ""; } + NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i).getNodeName().equalsIgnoreCase("chapter") @@ -183,8 +178,26 @@ public static BibleBook parseXML(Node node, int defaultBookNum, String defaultBo BibleChapter chapter = BibleChapter.parseXML(list.item(i), i); chapter.setBook(ret); ret.addChapter(chapter); + + if (ret.bookName == "" && i == 0) { + Node caption = list.item(i).getFirstChild(); + if (caption != null && caption.getNodeName().equalsIgnoreCase("caption")) { + ret.bookName = caption.getNodeValue(); + } + } } } + + if (ret.bookName == "") { + ret.bookName = defaultBookName; + } + + if (node.getAttributes().getNamedItem("bsname") != null) { + ret.bsname = node.getAttributes().getNamedItem("bsname").getNodeValue(); + } else { + ret.bsname = ret.bookName; + } + LOGGER.log(Level.INFO, "Parsed " + ret.getChapters().length + " chapters in " + ret.bookName); return ret; }