[sword-devel] modules to relational database
Martin Gruner
mg.pub at gmx.net
Tue Nov 7 13:28:06 MST 2006
Hi Troy,
> Martin, not to be rude, but have you actually personally used SWORD to
> display a tree structure?
Well we gladly use it in BibleTime to display Genbooks, as you know. =)
> Have you attempted to represent a tree
> structure in a RDBMS?
Yes. I learnt of it at work, where we use tree databases with Perl a lot.
> I'm not saying it can't be done. I'll just post
> the SWORD API exposed for this purpose, and let you and others decide if
> it is more convenient than SQL. From treekey.h
> (http://crosswire.org/svn/sword/trunk/include/treekey.h):
>
> /** Go to the root node
> */
> virtual void root() = 0;
>
> /** Go to the parent of the current node
> * @return success or failure
> */
> virtual bool parent() = 0;
>
> /** Go to the first child of the current node
> * @return success or failure
> */
> virtual bool firstChild() = 0;
>
> /** Go to the next sibling of the current node
> * @return success or failure
> */
> virtual bool nextSibling() = 0;
>
> /** Go to the previous sibling of the current node
> * @return success or failure
> */
> virtual bool previousSibling() = 0;
>
> /** Does the current node have children?
> * @return whether or not it does
> */
> virtual bool hasChildren() = 0;
>
> virtual void append() = 0;
> virtual void appendChild() = 0;
> virtual void insertBefore() = 0;
This is correct. It can be done with Sword, and well so!
Atm this is limited to Genbooks, though, and offers only partial access to the
module's XML structure (chapters). And (correct me if I'm wrong) it cannot
work with milestone-like elements.
The functions listed above can be transformed to very simple, probably
one-line SQL statements, except for the last three, which offer write access.
God bless,
mg
More information about the sword-devel
mailing list