<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jan 11, 2014, at 9:48 PM, Greg Hellings <<a href="mailto:greg.hellings@gmail.com">greg.hellings@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">for (Key key : book.getKey(requestedReference)) {</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"> BookData data = new BookData(book, key);</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"> </div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"> System.out.println(OSISUtil.getCanonicalText(data.getOSISFragment()));</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">}</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">This works fine for Bibles. I can iterate a single chapter, verse range, book, etc in a Bible. I can get out any entry in a Dictionary. I can even get the contents of a Gen Book if that sub-tree is only one level deep. E.g. I can get out Pilgrim's Progress 'SOURCE' section or 'TITLE' section. But I can't get out 'THE_AUTHOR'S_APOLOGY_FOR_HIS_BOOK' or 'PART_I'. Both of them throw a NoSuchKeyException, although getGlobalKeyList() returned a key whose OSIS ID claims to be equal to that string. Am I doing something wrong here, or breaking some sort of assumption about module types?</div></blockquote><div><br></div>From memory:</div><div><br></div><div>The basic idea is that *a* key is either a leaf node or it can have (i.e. has) children.<br></div><div><br></div><div>So given a top level key. You'll need to ask it if it has children. If it does then you need to get them with that key's iterator.</div><div><br></div><div>This is true of every key: it implements hasChildren() which is a test that is needed before getting the children. And there are a variety of ways to get the children.</div><div><br></div><div>1) By iterator (it has multiple semantic depending on whether a Key is a single item, a list or a node in a tree)</div><div>2) by number (with key.getChildCount(), key.get(n)) (You can also reverse the call of get(n) with key.indexOf(c))</div><div><br></div><div>You'll either need recursion or a stack to do a depth first processing of the tree. I don't think we've had a use case for having that in JSword. So far getting the children has been by user demand.</div><div><br></div><div>The string that is used for a key in a gen book is a path from the root. I forget the representation of the path. I don't remember if there is a lookup given a path.</div><div><br></div><div>Given the above it is pretty easy. Split the path into a list. Match at the top level, iterate over the children until a match of the next level and repeat until last level is processed.</div><div><br></div><div>Hope this helps.</div><div><br></div><div>And welcome to the JSword world.</div><div><br></div><div>BTW, you may want to look at o.c.j.bridge and o.c.j.examples. For the most part I try to keep these up as a simple tutorial. Bridge is meant to be a collection of useful programs in their own right.</div><div><br></div><div>In Him,</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>DM</div><br></body></html>