Uploaded image for project: 'JSword'
  1. JSword
  2. JS-291

Getting Hierarchical GenBook content also returns content of all child keys

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: o.c.jsword.book
    • Labels:
      None

      Description

      When attempting to retrieve the content of a single GenBook key (TreeKey) all child content of the key is also returned. It did not do this a couple of years ago but I don't know how long this problem has existed.

      E.g. In Josephus the following hierarchy exists:

          78:The Antiquities of the Jews
              79:Preface
                  80:Section 1
                  81:Section 2
                  82:Section 3
                  83:Section 4
      

      but attempting to retrieve Preface also retrieves Section 1-4.

      Debugging into the junit below the iterator called as part of bookData.getOsisFragment() iterates all child keys. Ideally it should not iterate child keys but I am not sure of the best way to fix this.

      Here is a junit demonstrating the problem:

          @Test
          public void testHierarchicalBook() throws Exception {
              Book josephus = Books.installed().getBook("Josephus");
              String Section1Text = "THOSE who undertake to write histories";
              if (josephus != null) {
                  // navigate down to the Preface
                  Key theAntiquitiesOfTheJewsKey = josephus.getGlobalKeyList().get(1);
                  Key prefaceKey = theAntiquitiesOfTheJewsKey.get(0);
                  String prefaceText = josephus.getRawText(prefaceKey);
                  // this test passes
                  assertFalse("Child keys returned in raw text", prefaceText.contains(Section1Text));
                  
                  // Now attempt to parse a key but get the problem is that all child text is returned too 
                  BookData bookData = new BookData(josephus, prefaceKey);
                  final Element osisFragment = bookData.getOsisFragment();
      
                  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
                  String prefaceXml = xmlOutputter.outputString(osisFragment);
                  System.out.println(prefaceXml);
                  
                  // this test fails
                  assertFalse("Child keys returned in xml", prefaceXml.contains(Section1Text));
              }
          }
      

        Attachments

          Activity

            People

            • Assignee:
              dmsmith DM Smith
              Reporter:
              mjdenham Martin Denham
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: